Fork me on GitHub
#re-frame
<
2022-11-11
>
mister_m04:11:04

Hi This could be in the weeds a bit, but I am reading the documentation and arrived at the https://day8.github.io/re-frame/Talking-To-Servers/#version-1. It gives an example Version 1 which makes an ajax request then dispatches events based on the response. I agree the event handler isn't pure. The documentation-suggested way to make this request is to leverage reg-event-fx to return a series of effects one of which is the :http-xhrio effect. https://github.com/day8/re-frame-http-fx/blob/master/src/day8/re_frame/http_fx.cljs#L98 this is just an effect handler. I understand that the Version 2 example is now using an "effect" instead of an event handler. However, I don't understand what makes invoking the effect handler "pure" when it still is eventually - somewhere - doing the ajax request. What is the differentiator between the two that allows using a req-event-fx handler performing a side effect to be "pure"?

mister_m04:11:15

Actually I may have just found it - the special do-fx interceptor that is inserted into every effect handler's interceptor list? Is that unique to req-event-fx ?

p-himik07:11:26

reg-event-fx and a much less used reg-event-ctx.

p-himik07:11:58

reg-event-db also uses it but only for the :db effect - you have no control over that.