This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-01
Channels
- # announcements (1)
- # beginners (71)
- # calva (12)
- # cider (3)
- # clj-kondo (12)
- # cljsrn (9)
- # clojure (167)
- # clojure-dev (21)
- # clojure-europe (5)
- # clojure-italy (60)
- # clojure-nl (6)
- # clojure-spec (6)
- # clojure-uk (60)
- # clojurescript (86)
- # core-async (25)
- # cursive (21)
- # datascript (9)
- # datomic (4)
- # figwheel (8)
- # fulcro (7)
- # graalvm (4)
- # jackdaw (6)
- # jobs (8)
- # juxt (2)
- # leiningen (1)
- # malli (1)
- # off-topic (20)
- # re-frame (31)
- # reagent (5)
- # remote-jobs (3)
- # shadow-cljs (57)
- # sql (6)
- # vim (9)
sometimes hot-reload a bad code may break the render. is it possible to recovery the UI without reload the browser.
Single fx means?
(reg-fx :foo (fn ...))
(re-frame/dispatch [:foo])
This won't work, because fx is not event.I typically create two registrations reg-event-fx :foo
and reg-fx :foo
where the first triggers the second. Another thing you can do is create the var foo-fx
and then bind that function to reg-fx :foo
- you can then invoke it as a regular function where it makes sense (probably within a lifecycle method?). I would go with the first approach though and keep it 100% within re-frame.
May I ask one more question:joy: Can I have some async flow in the cofx.
The case is, assuming there's a AsyncStorage, I want use inject-cofx
to get a item, inject the item to cofx
then dispatch the event.
Is it possible or am I on the wrong way?
This is a lib that works with localStorage and does that. https://github.com/akiroz/re-frame-storage/blob/master/src/akiroz/re_frame/storage.cljs#L54
yes, I can use localstorage like this, but in React Native, the storage has an async API. it can't be used like this.
I know how to do this with a chain like event -> fx -> event. But what if use cofx injection?
Holà!
I use re-frame-http-fx
to perform a POST
request. I just send a string in the body. The request is "OK", I got a status 200, but also an error (JSON.parse: unexpected keyword at line 1 column 1 of the JSON data Format should have been JSON keywordize). So the request goes for :on-failure
and not :on-success
whereas it is executed and the API consumed the string.
Can I fix it without touching the code from API ?
@scknkkrer well, I implemented the POST
request from a colleague's postman collection. And the body is just a string
Can you send an example output from the Request
you are trying to do ?
Explicitly, in code
tags ?
Yeah, maybe you can. I don’t know the details about re-frame-http-fx.
You can solve your issue with wrapping it by quotes, before you parse it as JSON
.
Sorry, I can’t help with the implementation details.
But;
I’ve written a library called Suluk
for this.
Fetch API
wrapper for Clojurescript.
You can quickly look at it’s documentation.
https://github.com/LeaveNhA/suluk
I’m waiting for your feed-back, @U050PEFK2.
you can define the response-format that you expect and just use ajax/text-response-format
Is there a good pattern (or even example) on how to wrap a subscription within another subscription?
You could use one subscription's data inside another — is that what you're looking for? Like https://github.com/Day8/re-frame/blob/ce4c580dfc24e120b932f4aebf000a85b426543e/examples/todomvc/src/todomvc/subs.cljs#L49-L52