Fork me on GitHub
#re-frame
<
2018-02-01
>
piotr-yuxuan01:02:31

https://github.com/piotr-yuxuan/dispatch-n-bug-mwe I’m pretty it’s not a bug in re-frame, however I find the behaviour described in this project very unexpected. I expect events to be sequentially processed as a queue, but this project exhibit something that looks like it’s different. Any hint?

mikethompson02:02:28

@piotr2b when events are dispatched, they are placed into an FIFO queue.

mikethompson02:02:56

Hmm. My comment above doesn't exactly address your question/problem, BUT that repo's README has an Aw, found it! section ... so I assume you are good now?

mikethompson02:02:26

BTW: my new suggestion (to almost everyone) is to observe your app's functioning via re-frame-trace

shaun-mahood17:02:11

@danielcompton: In the new version of re-frame-trace, would it be possible to have a dropdown that lists all of the epoch events? I took a quick look at at the code around it and it looks complex enough that I figured I check if there were any fundamental blockers before putting much time in to investigating it. Also, I'm loving the information in the new event panel!

caleb.macdonaldblack21:02:27

I’m curious about the intention behind using a vector as the argument in re-frame dispatch and subscribe functions? It makes it impossible to partial without wrapping. I’m also curious as to any issues I might run into if I did wrap the dispatch and subscribe to make it possible to partial.

mikethompson23:02:07

@caleb.macdonaldblack I'm not sure what you mean by "to partial"

mikethompson23:02:25

So I can't answer the second part of your question. But, regarding the frist part ... events are data ... I chose a vector because visually it has less noise than a map. The only two choices were vector or map. map would have become my choice if I thought events were going to be complicated, but they are generally simple

caleb.macdonaldblack23:02:17

@mikethompson (partial rf/dispatch :my-event-key some-data)

mikethompson23:02:02

Instead, just use conj

mikethompson23:02:12

the event is a vector

mikethompson23:02:18

conj onto the end of it

mikethompson23:02:11

Also, one of these days there might be a version of re-frame where dispatch takes a 2nd parameter

caleb.macdonaldblack23:02:15

Ahh okay so the reason for it being a vector is to future proof it when and if dispatch ever needs a second parameter?

caleb.macdonaldblack23:02:47

Which would mean an update like that wouldn’t break any existing projects

mikethompson23:02:48

Partially, yes (pun intended)

mikethompson23:02:34

data is a more powerful substrate than functions. data is the ultimate in late binding.

caleb.macdonaldblack23:02:00

So thats really interesting because functions that take an arbitrary length of params should probably just take a vector to make them easier to change later.

caleb.macdonaldblack23:02:35

Unless the function is extremely unlikely to change such as some of the core functions in clojure

mikethompson23:02:47

I wanted events to be modelled as data, not just be args

caleb.macdonaldblack23:02:35

Yea I can see that too. So you could pass a vector in, make some changes and dispatch without needing to use apply for example

mikethompson23:02:57

This perspective was at the back of my mind (although it took a while for me to realise what was guiding my thinking) https://github.com/Day8/re-frame/blob/master/docs/MentalModelOmnibus.md#on-dsls-and-machines

caleb.macdonaldblack23:02:34

Thanks, I definitely learned something here. :thumbsup: