This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-28
Channels
- # 100-days-of-code (10)
- # announcements (2)
- # architecture (16)
- # beginners (51)
- # bitcoin (3)
- # calva (1)
- # cider (6)
- # cljdoc (8)
- # cljs-dev (14)
- # cljsrn (4)
- # clojure (59)
- # clojure-italy (26)
- # clojure-losangeles (1)
- # clojure-nl (13)
- # clojure-spec (54)
- # clojure-uk (81)
- # clojurebridge (4)
- # clojurescript (20)
- # core-async (16)
- # cursive (39)
- # datomic (27)
- # emacs (12)
- # events (1)
- # figwheel-main (20)
- # fulcro (35)
- # funcool (1)
- # graphql (9)
- # hyperfiddle (10)
- # jobs (1)
- # jobs-discuss (7)
- # keechma (10)
- # lumo (22)
- # nrepl (18)
- # off-topic (28)
- # onyx (3)
- # pedestal (4)
- # re-frame (8)
- # reagent (8)
- # ring (4)
- # rum (3)
- # shadow-cljs (29)
- # testing (5)
folks, anyone figured out how to use re-frame-http-fx
on React Native? I can’t get it to work because of failing dependency on xmlhttprequest
module
@xfyre I got it working by just copying the source file to my project and installing dependencies manually. This was last December so things may have changed since.
@valtteri actually I figured out what the problem is, but didn’t figure out a solution yet https://github.com/JulianBirch/cljs-ajax/issues/188 one obvious workaround is downgrading re-frame-http-fx to 0.1.4
@xfyre I think I encountered the same issue but I can’t remember the exact details. 😕 From git it seems like I’ve ended up copying the source of re-frame-http-fx
under src
and declaring dependency to cljs-ajax
manually in project.clj
. I’ll try to see if I can find any notes why I ended up doing exactly that.
Nah, apparently I didn’t make any notes but I hope you’ll find the solution that works for you also.
Can someone give me some guidance on dealing with promises in re-frame? I have a client API that returns promises, though I can't figure out how to handle it.
(rf/reg-sub
:client
:<- [:credentials]
(fn [credentials]
(when credentials
(create-client credentials))))
(rf/reg-sub-raw
:request
(fn [_]
(let [a (r/atom nil)
client @(rf/subscribe [:client])]
(.then (.query client)
#(reset! a (js->clj %)))
(ratom/reaction @a))))
Part of the problem is that in order to create my client, I need to do some credentials federation first, so (rf/subscribe [:client])
is nil
for the first few seconds.
I've tried a number of ways of having the @(rf/subscribe [:client])
inside the reaction, but the problem is that it causes an endless loop.Essentially, whenever [:client]
changes, I need to issue the request, however I don't want to reissue the request once the r/atom
(or db
) changes.
Is there a cleaner way than this?
(rf/reg-sub-raw
:example
(fn [_]
(let [a (r/atom nil)
b (ratom/reaction
(let [client @(rf/subscribe [:client])]
(when client
(.then (.query client)
#(reset! a %)))))]
@b
(ratom/make-reaction
(fn [] @a)
:on-dispose #(ratom/dispose! b)))))