Fork me on GitHub
#re-frame
<
2019-02-24
>
mikethompson00:02:55

@r.natarajan35 you should probably just start with Reagent and forget re-frame for a while. But ultimately re-frame (or something like it) will become necessary (depending on the complexity of the apps you develop) https://github.com/Day8/re-frame/blob/master/docs/FAQs/DoINeedReFrame.md

mikethompson00:02:35

@witek for me, it would be a code smell to see multiple dispatches in a single button's on-click

mikethompson00:02:58

But, yes, technically, you can do it

mikethompson00:02:24

It is code smell because I believe an event should model "user intent".

mikethompson00:02:42

When a user clicks a button they want one thing to happen.

mikethompson00:02:48

So there's one event dispatched

mikethompson00:02:13

Where people often get this wrong is when they imagine dispatching events to be like "calling a function"

mikethompson00:02:43

So the user clicks the button and they want to "call multiple functions" to implement the user's goal

mikethompson00:02:55

So they want to dispatch multuple times

mikethompson00:02:14

I believe this is the wrong way to think about things

mikethompson00:02:28

The button should cause one event to be emitted

mikethompson00:02:43

The event handler for that event is what can call multiple functions to get the job done.

mikethompson00:02:03

So: 1. The event models the user's intent. 2. The associated event handler implements that intent

mikethompson00:02:08

BTW, sometimes events also model triggers from OTHER external actors, like "arriving websocket message" or HTTP GET response. But mainly they are modelling the user (as an external actor and initiator of triggers)

mikethompson01:02:14

To put this yet another way ... your events collectively implement "the language" that your application understands. They implement the set of things to which your application can respond. Events do not model implementation (function calls).