Fork me on GitHub
#scittle
<
2022-12-24
>
jurjanpaul14:12:17

I just noticed that not all of Reagent is exposed (in/via https://github.com/babashka/sci.configs/blob/main/src/sci/configs/reagent/reagent.cljs), now that I started looking whether I can make output render in the middle of a long (AoC) calculation, e.g. using reagent.core/flush and/or reagent.core/force-update (no experience with either, so I'm not even sure whether it would work). Is that deliberate or something that could be added when the need/wish comes up? 🙂

borkdude15:12:30

Feel free to add it via a PR :)

jurjanpaul15:12:32

👍 Great! I’ll take my time though 🙂 (to figure out how it all works and whether it would actually help).

borkdude15:12:02

you can build scittle locally and try it

jurjanpaul22:12:07

Well, that was indeed straightforward enough to test, as I should have known. 🙂 And no: it doesn't actually solve anything. So, no PR.

borkdude22:12:20

@jurjanpaul502 Perhaps it will help if you make your long AOC calculation async, so the render can go in between

jurjanpaul22:12:25

You are right of course that that would work (and be the only way probably): slice the algorithm(s) up into subroutines that would only run for small amounts of time at a time. More than about AOC itself though, this was about hoping to make ape-cljs-playground both responsive + beginner-friendly, so you could get output while running expensive code, by using (flush) (or something like it) every now and then (instead of requiring async knowledge). That this appears infeasible seems to have less to do with single-threadedness or Reagent itself, but with (perfectly sensible, I trust) choices within React w.r.t. what you can do from an event handler. Not seeing any low-hanging fruit, I'll leave the idea alone for now (although: I'll probably think some more about whether re-frame might help here after all).

👍 1
jurjanpaul07:12:11

Overthinking out loud :man-facepalming:🙂 flush should of course just bypass Reagent and update the DOM node directly.

jurjanpaul11:12:07

Well... no. Single-threadedness after all.