zendevil 2021-03-07T07:37:33.125400Z

I have the following effect:

 (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?

zendevil 2021-03-07T07:42:38.125700Z

I want to get rid of the dispatch

zendevil 2021-03-07T08:07:48.125900Z

is there a way to do that?

Lu 2021-03-07T09:31:35.128600Z

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

p-himik 2021-03-07T09:34:21.130Z

Regardless of the callback - effects are supposed to be impure. IMO the code above is perfectly fine.

Lu 2021-03-07T09:36:00.131100Z

Oh yeah that fx is already impure without the dispatch :) so if that’s the concern there’s nothing to add

aaron51 2021-03-07T23:58:17.132600Z

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.