Fork me on GitHub
#re-frame
<
2018-07-04
>
troglotit07:07:23

@p-himik I’d recommend looking for this https://github.com/Day8/re-frame-async-flow-fx#advanced-use The :dispatch-fn allows for inspecting data of incoming event vectors.

troglotit07:07:26

It basically allows for regular callbacks using correlation-ids, so you know by which specific event next one was invoked.

pesterhazy08:07:25

to answer my question, it "exists for historical reasons and is borderline deprecated these days" (https://cljdoc.xyz/d/re-frame/re-frame/0.10.5/api/re-frame.subs#subscribe)

p-himik09:07:42

@troglotit Thanks for the links. Not sure I follow though. How would that work in the trivial example above with :start and :end with an xhr request in between?

troglotit11:07:17

you can see that I have :http request but it used only in :request event. :request then calls invokes :request-success or :requst-failure with passed request-id https://gist.github.com/troglotit/fa52d56bf6add4dab400c251a056c1b4#file-events-cljs-L65 and then on https://gist.github.com/troglotit/fa52d56bf6add4dab400c251a056c1b4#file-events-cljs-L65 I wait for :request-(success|failure) of my request-id

troglotit11:07:09

It requires quite dramatic change of usage of effects like :xhr

troglotit11:07:28

Quite hard to provide “quick and easy” solution

p-himik11:07:33

Also, I think that it complicates things quite a bit because I don't need something like a generic handler for a success of an http request. Different requests in my application always have different handlers.

troglotit11:07:51

Here’s example of business logic: I can pass args to my next “callback events” and I know that at last position there will be my payload.

p-himik11:07:39

The above snippet by itself is surely possible to implement without :async-flow and request-flow with about the same number of lines.

troglotit11:07:15

Hmm, yeah 🙂 but it enables true “event processing” with combining any amount of chain of async stuff without losing any context of which event had been produced.

p-himik11:07:24

But these chains will be ad-hoc in each and every case, and hence it's not different from composing them by yourself since each variation of :on-success of each effect already accepts arbitrary arguments and appends the result as the last argument. Well, at least in my case.

4