Fork me on GitHub
#re-frame
<
2021-07-25
>
ribelo20:07:50

I have a bizarre problem with callback hell, despite using async-flow Let's say I have an event ::fetch-from-x that takes an argument and ::fetch-from-y that also takes an argument, plus y needs data stored by x. When processing [::fetch-from-y "bar"], I check if I have the needed data in the db and if I don't, then:

{:fx [[:async-flow
              {first-dispatch [::fetch-from-x "foo"]
               :rules [{:when :seen?
                                 :events ::fetch-from-x-success
                                 :dispatch [::fetch-y "bar"]
                                 :halt? true}]}]]}
if I call ::fetch-from-y several times with different arguments, async-flow does not allow to check witch ::fetch-from-x event succeeded 😞

AJ Jaro10:07:20

@U0BBFDED7 https://github.com/day8/re-frame-async-flow-fx#under-the-covers async-flow keeps track of events that have already ran. With this design it only allows each rule to be run once Someone also https://github.com/day8/re-frame-async-flow-fx/issues/15 to track something similar to what you’re looking to do

ribelo10:07:49

Well, I've managed a not so elegant solution, I push the on-success, event after the event, which are all fired in the right order after the data is fetched

ribelo11:07:42

Looks bad, works surprisingly well, hope I don't have to touch it again

👍 2