I guess you would use s/cat a lot
I still donβt know how you can spec a JS object
is there any way for me to update a component every time a function runs through a loop? I have a function that conjs a string onto an atom on every loop and I want a component to update the displaying of the string incrementally
If by "in a loop" you actually mean loop
, then I don't think so because by hogging the only thread the browser's JS has, you prevent anything from re-rendering.
ah thats unfortunate π thank you
There's this but I have no idea if it can help here: http://reagent-project.github.io/docs/master/reagent.core.html#var-force-update
I've tried that and it seems to halt the loop where I call it
I'll try to see if I can implement the same function without the loop
You can employ requestAnimationFrame
to split the iterations. This way, the browser will have a chance to render something between the iterations.
I looked up how to use requestAnimationFrame and I still don't quite understand how to use it. Could you elaborate?
I tried calling (.requestAnimationFrame js/window output)
at the end of the loop, and it doesn't seem to be doing anything worthwile
You completely replace loop
with calls to requestAnimationFrame
.
https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Notes
whoa. Really cool. Thank you!