A minimalistic ClojureScript interface to React.js

I guess you would use s/cat a lot


I still don’t know how you can spec a JS object

Sung 2020-06-20T08:38:30.197200Z

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-himik 2020-06-20T08:40:13.197400Z

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.

Sung 2020-06-20T08:40:57.197600Z

ah thats unfortunate 😞 thank you

p-himik 2020-06-20T08:42:00.197800Z

There's this but I have no idea if it can help here:

Sung 2020-06-20T08:42:26.198Z

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

Sung 2020-06-20T08:42:43.198200Z

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

p-himik 2020-06-20T08:43:22.198400Z

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

Sung 2020-06-20T09:07:17.198700Z

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

Sung 2020-06-20T09:08:17.198900Z

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

p-himik 2020-06-20T09:11:40.199100Z

You completely replace loop with calls to requestAnimationFrame.

Sung 2020-06-20T09:14:08.199700Z

whoa. Really cool. Thank you!