re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
2020-06-27T12:11:24.087100Z

New explanation of dominoes 1,2,3

1👍
2020-06-27T12:11:26.087200Z

Marlus Araujo 2020-06-29T15:29:58.128700Z

Newbie question: how is the best way to dispatch events that has no db side-effects? To return db is always required? (reg-event-db :test-signal (fn [db _] (js/console.log "signal was tested!") db))

2020-06-27T12:12:00.088Z

What am I not explaining well? What is confusing? What needs more clarification or more detail or less detail?

2020-06-27T12:13:46.089200Z

This is a question particularly for those currently learning re-frame, but please jump in with any thoughts if you can still remember what it was like to be new

p-himik 2020-06-28T07:05:35.107100Z

@jahson If you have effects like e.g. :db and :dispatch in the result of a single event handler, you cannot know what effect handler will be called first - for :db or for :dispatch. But the changes in the DB will be there before the event handler for the event mentioned in :dispatch is called. Because the effect handler for :dispatch doesn't do anything but put the event on the FIFO queue.

p-himik 2020-06-28T07:06:44.107300Z

Since the queue is FIFO, as mentioned in the infographic, the event will be scheduled to run last as compared to other events that are already there.

2020-06-28T14:35:01.116800Z

@p-himik Thanks for clarification. I know about effects and FIFO queue, I was talking about seeing people being confused.

2020-06-28T14:50:37.117Z

And if you have your own effect handler, you cannot rely on app-db being updated before that effect handler. IIRC this is even mentioned somewhere in docs.

p-himik 2020-06-27T12:25:27.089300Z

There have been a few questions on the ordering of :dispatch, :db, and other effects. I know that the information is there on the diagram, but maybe it's not immediately obvious. Do you think it could be emphasized somehow? Or maybe an additional diagram (or text with [pseudo]code blocks) would be more appropriate.

2020-06-27T12:32:59.090Z

The existing infographic, which I am partially replacing, seems to make the point about a queue clear but .... it has never stopped the questions https://day8.github.io/re-frame/event-handling-infographic/

2020-06-27T12:33:35.090800Z

So I'm a little pesemistic about getting that idea across via an infographic

gekkostate 2020-06-27T12:36:02.092700Z

This is not quite related to the new explanation but it would be great if there was an additional explanation for “layer 3” subscriptions. Are “layer 3" subscriptions, beneficial only for doing additional computation? Or is it also that, by adding layer 3 subscriptions, we render less? Eric Normand in his https://purelyfunctional.tv/guide/re-frame-building-blocks/#subscriptions suggests that with layer 3 subscriptions, components will re-render less but it’s not entirely clear why.

2020-06-27T12:36:06.092900Z

This new one continues the idea of noting (in small text, granted) that the queue is FIFO

2020-06-27T12:36:58.093500Z

@gekkostate I'm wondering if you have seen this page:

2020-06-27T12:37:57.094400Z

I added it in the last 6 weeks or so

2020-06-27T12:38:09.094700Z

Perhaps it is a bit hidden in the "intermediate section"?

2020-06-27T12:41:04.096300Z

And, to answer you question, layer 3 are not about less rendering (in general). The propagation pruning layer is Layer 2. Layer 3 is about performing the the expensive computation.

2020-06-27T12:41:54.097300Z

Now, in theory, it is possible for an expensive computation to be the same as "last time" and, as a result, for there be no further propogation to the views, but that's kinda unusual in practice.

gekkostate 2020-06-27T12:43:04.097500Z

Yes! So I really like this page. The infographic is super helpful. I like that there’s a section especially for “Why Layer 2” because it makes the relationship between layer 2 and the layers very clear.

gekkostate 2020-06-27T12:44:31.098500Z

Right! That makes sense. I read the explanation that in the subscriptions doc and then contrasted it with Eric’s and was a tad confused. I think it would be helpful to have what’ve you just said in the docs.

p-himik 2020-06-27T13:05:42.099100Z

Mmm, yeah, I see.

2020-06-27T16:14:03.099900Z

I thought expensive computation should have been done in events haha

2020-06-28T07:03:40.105400Z

Thanks.

2020-06-28T07:05:00.106800Z

How does it reconcile with this page then? http://day8.github.io/re-frame/Solve-the-CPU-hog-problem/

2020-06-28T07:07:23.107500Z

That page is about cases where you have to do lots of CPU intensive calculations in an event handler, which will tie up the execution thread for too long. It is about how you periodically hand back control to the browser. I'm not sure it is related to the question of what should happen in events and what should be done in subscriptions

2020-06-28T11:48:41.111100Z

Well, I thought it was recommending to put heavy computing in event handlers?

2020-06-28T11:49:36.112400Z

So it recommends to not do them in subscriptions? I am sorry if it seems confusing.

2020-06-28T13:17:02.116200Z

I think it depends on what you mean by "heavy computing". Something that locks up the thread for many seconds and stops redraws should be done in an event handler, yes, and not in a subscription. And that page show you how to chunk that computation down to time into smaller slices.

2020-06-28T15:31:47.117300Z

Thanks!

2020-06-27T21:10:13.100100Z

I thought the first message from @p-himik was about non-guaranteed order of effect processing, but I'm confused now.

2020-06-27T21:14:04.100300Z

I've also seen people being confused about :dispatch and :dispatch-n effects. Like, where these new events would appear? After their "source" event or after the last event in queue?

2020-06-27T21:16:29.100500Z

There's also dominos / dominoes in this picture.

gekkostate 2020-06-27T21:25:02.100900Z

I think the rationale for doing it in the subscription is that you will only need to calculate when you need it. So, we’re essentially delaying calculation until necessary. Otherwise, we’re calculating without use.