This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-07
Channels
- # announcements (19)
- # babashka (19)
- # beginners (76)
- # bitcoin (2)
- # calva (1)
- # chlorine-clover (1)
- # cider (7)
- # clara (1)
- # clj-kondo (1)
- # cljsrn (1)
- # clojars (4)
- # clojure (139)
- # clojure-dev (65)
- # clojure-europe (2)
- # clojure-uk (2)
- # clojurescript (7)
- # community-development (3)
- # conjure (15)
- # core-async (5)
- # cursive (11)
- # data-science (9)
- # duct (6)
- # fulcro (4)
- # honeysql (12)
- # jobs (3)
- # jobs-discuss (3)
- # keechma (1)
- # malli (31)
- # meander (14)
- # midje (1)
- # off-topic (21)
- # pathom (6)
- # practicalli (3)
- # quil (7)
- # re-frame (10)
- # reitit (6)
- # slack-help (4)
- # tree-sitter (6)
- # xtdb (1)
I have the following effect:
(reg-fx
:launch-image-library
(fn [navigation]
(launchImageLibrary (clj->js {:mediaType "photo" :quality 0.1})
(fn [res]
(dispatch [:add-date-time navigation (get (js->clj res) "uri")])
))))
Is there a way that I can make it pure?I want to get rid of the dispatch
is there a way to do that?
well the event gets called in a callback.. not sure you can easily remove it.. if that’s the only place where you do the :add-date-time logic maybe you can just hard code it straight into the callback
Regardless of the callback - effects are supposed to be impure. IMO the code above is perfectly fine.
Oh yeah that fx is already impure without the dispatch :) so if that’s the concern there’s nothing to add
What’s a good pattern for “Fire event X after A, B and C are fired asynchronously”? In the browser, we need to load data from several sources, simultaneously, and only render the DOM when the loads are complete.
Depends on specifics. If A, B, and C just happen once and that's it, then https://github.com/Day8/re-frame-async-flow-fx
There is also https://github.com/ingesolvoll/re-chain (although I've not used it)