Fork me on GitHub

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?


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


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?


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.


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.