Fork me on GitHub
#re-frame
<
2020-08-06
>
sandbags11:08:14

In the re-frame docs (http://day8.github.io/re-frame/Effects/) it refers to "`re-frame's` built-in effect handlers, like `dispatch-n` and `dispatch-later`, are detailed in https://day8.github.io/re-frame/codox/ document." But on that page I see defined only dispatch and dispatch-sync . What am I missing?

sandbags11:08:21

Actually I am not sure that codox page is working. None of the links do anything for me (Chrome 84, macOS 10.14.6)

sandbags11:08:51

I'm trying to remember how one should dispatch events from an event handler. I suspect using dispatch-async directly is counter-indicated and you should be using reg-event-fx and having something else trigger the dispatch but I can't seem to find it in the docs.

sandbags11:08:35

Found it, in the Effects: Two Step Plan section, returning {:dispatch […]}

sandbags11:08:02

It seems like either {:dispatch []} is an example not implemented or there is magic functionality that makes it work not documented. For example if I want do dispatch two events as a side-effect, can I :dispatch [[evt1][evt2]]?

sandbags11:08:05

Okay have found what I need in fx.cljc

mikethompson12:08:41

@sandbags Sorry, that link on that page is old and wrong (now corrected). This is the link you should be using ... https://day8.github.io/re-frame/api/#api-builtin-effects.html

mikethompson12:08:38

It seems like you might want effects like this:

{ :db         (assoc db :something :else) 
  :dispatch-n (list [:first-event] [:second-event "yeah"])}

mikethompson12:08:40

^^^ note that's :dispatch-n and not :dispatch

sandbags13:08:32

Thanks @mikethompson I eventually ended up spelunking into fx.cljc but grateful for the confirmation. I've been away from re-frame too long!

mikethompson13:08:24

Glad to have you back :-)

😀 3
Grant Isom15:08:09

In our project, our views.cljs is growing pretty fast, are there any patterns or naming conventions for moving to a views folder then having files for each page or group of components?

David Pham15:08:05

I usually write a namespace for components that will work together. Similar to the hexagonal architecture.

6
sandbags18:08:09

Okay, I'll bite. Hexagonal architecture is a new one on me… where can I find out more?

David Pham18:08:57

It just means that you will write many fully qualified events and subs, and only few of them will be global and shared.

David Pham04:08:45

Yep! For re frame, the transport layer would be the events and subscriptions and entities would be the dB.

👍 6