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.