Fork me on GitHub
#reagent
<
2020-06-20
>
David Pham07:06:48

I guess you would use s/cat a lot

David Pham07:06:35

I still donโ€™t know how you can spec a JS object

Sung08:06:30

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

p-himik08:06:13

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.

Sung08:06:57

ah thats unfortunate ๐Ÿ˜ž thank you

Sung08:06:26

I've tried that and it seems to halt the loop where I call it

Sung08:06:43

I'll try to see if I can implement the same function without the loop

p-himik08:06:22

You can employ requestAnimationFrame to split the iterations. This way, the browser will have a chance to render something between the iterations.

Sung09:06:17

I looked up how to use requestAnimationFrame and I still don't quite understand how to use it. Could you elaborate?

Sung09:06:17

I tried calling (.requestAnimationFrame js/window output) at the end of the loop, and it doesn't seem to be doing anything worthwile

p-himik09:06:40

You completely replace loop with calls to requestAnimationFrame.

๐Ÿ‘ 6
Sung09:06:08

whoa. Really cool. Thank you!

๐Ÿ‘ 3