Fork me on GitHub
#re-frame
<
2020-04-19
>
jntn09:04:36

Is there any way to make sure just one instance of an event is called each animantionframe, even if there is more in queue? In other words, can I hook into the router queue somehow and modify it (removing all duplicate events), before all queued events is called

jntn10:04:05

I guess I could use add-post-event-callback? Just found it in the docs 🙂

jntn10:04:12

Hmm, I don’t see how I can modify the queue in add-post-event-callback…

p-himik10:04:16

You could modify re-frame.router/event-queue.

jntn10:04:32

Ah, I see! Thanks!

lilactown16:04:34

usually I think you would prefer to debounce calling the event

👍 4
p-himik16:04:50

If having the event dispatched at most once per animation frame is a hard requirement, debouncing won't help.

erwinrooijakkers18:04:00

I want to create an effect handler that kicks of another event on a javascript callback. What is a proper way to do this?

(re-frame/reg-fx
 ::zenroom
 (fn [script]
   (doto zenroom
     (.print (fn [s] #_here i want to dispatch or write to db for every time print happens in script))
     (.script script)
     .zenroom-exec)))

erwinrooijakkers18:04:51

So for every script .print can be called 0 to n times

erwinrooijakkers18:04:55

I want the results

erwinrooijakkers18:04:29

If someone has any ideas, can he or she please let me know? Maybe the whole reg-fx idea is wrong to start with

p-himik18:04:55

Just call dispatch in that fn with the comment.

erwinrooijakkers19:04:30

I thought about it but wasnt sure if it was the right approach