oliyh / re-graph

A graphql client for clojurescript and clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(re-frame/dispatch-sync [::re-graph/init {}])?

opened this issue · comments

Should ::re-graph/init be dispatched using dispatch-sync to ensure it completes before my code executes any subscriptions (e.g.)?

Hi,

Yes, it needs to be initialised before anything tries to use it. I init it with a normal dispatch and it works fine but it probably depends on how your code is arranged.

@mike-thompson-day8 says that events are handled in a FIFO manner and points to a comment in the source of re-frame.router for a more detailed explanation: https://github.com/Day8/re-frame/blob/e539ff6548acd014f9c3da5797918fa5fa4eb818/src/re_frame/router.cljc#L8-L61

Hence simply ordering the dispatches correctly will usually be sufficient.