Fork me on GitHub
#reagent
<
2020-09-10
>
neilyio20:09:48

Is reagent/next-tick a drop-in replacement for requestAnimationFrame? I can't find much literature on it. What would be the equivalent of cancelAnimationFrame?

p-himik20:09:50

It is equivalent, I think. And its docstring confirms that. But there's no canceling functionality.

neilyio20:09:07

Thanks! I suppose I'll use requestAnimationFrame instead so that I can cancel it... Unless it's less important than I thought to use cancelAnimationFrame?

p-himik20:09:39

I cannot answer in any useful way without knowing what you're actually doing. Maybe canceling the callback is required, maybe it's preferred but not necessary, maybe it isn't necessary at all. Either way, I don't see how canceling something when you know that you don't need it would be a bad idea.

neilyio20:09:00

Upon more reading, it seems to me that a common pattern is for requestAnimationFrame 's callback to call itself recursively. Each recursive iteration checks a stopping condition, and either returns or calls requestAnimationFrame once again. If this is also the common practice with reagent/next-tick, I can see how a "cancel" function becomes unnecessary.