Fork me on GitHub
#hyperfiddle
<
2023-12-01
>
Tommy Jolly21:12:49

I think I'm missing something obvious here - Using an ui4/button, something like (e/defn Thing [db] ,,, (ui4/button (e/fn [] (e/server (side-effects!) nil)) ,,,)), the button continues firing and running side-effects! recursively until it (eventually) causes itself to be unmounted. Is this because side-effects! mutates the db that's passed to Thing, causing it to re-mount? and/or because it's in some kinda "pressed" state that the callback fn could disable?

xificurC22:12:58

Mutating the db creates a cycle. Search for e/offload in the channel for previous discussions

Tommy Jolly23:12:16

Yes! e/snapshot worked for me - I'll use that as a workaround until UI5 obsoletes it. I don't understand e/offload, on an ELI5 level, does it effectively run something asynchronously? (while letting you optimise for the type of bottleneck you expect)

Tommy Jolly10:12:22

Don't worry, I found a quote: "`e/offload` moves a blocking computation to a threadpool (see docstring), so as not to block the reactive computation. databases are slow and blocking (even transact) so all database operations must be offloaded" 👍

henrik12:12:02

I don’t see how offload prevents cycles without combining with snapshot. Or if it does, it raises other questions, like how come reactive updates to queries using db as input works?

xificurC18:12:40

I meant to write e/snapshot. Shows why replying at night is not a great idea