Fork me on GitHub
#reagent
<
2021-08-29
>
Pepijn de Vos05:08:19

Is there a way to update two ratoms without causing flickering? My state is several completely disjoint parts except for a couple of functions that update both

p-himik07:08:58

If it's two consecutive calls to swap! or reset!, there should be no flickering at all. JS is single-threaded and Reagent doesn't react to ratom changes immediately, unless you call reagent.core/flush .

Pepijn de Vos08:08:43

Ah good. I had the feeling that when I did this before, it seemed to redraw in the middle of an series of updates. So I've tried consolidating my updates into larger swap! but in some places I need to update multiple things, for which I put everything in a mega atom.

p-himik09:08:09

Just to be clear - this

(swap! ratom1 do-stuff)
(swap! ratom2 do-stuff)
should not lead to flickering. Unless you use flush somewhere in do-stuff or, perhaps, add-watch. So there's no need to consolidate them into one ratom or one swap operation.