Waiting for a reactive to finish

Hi all,

I have a problem where I have a computationally intensive task, for which I am using await and yield so as not to freeze the browser. I have other cells that depend on the output, but using them in a reactive sense slows everything down. What I’d like to do is to have a status that only allows subsequent cells to execute after the main cell has finished - what are the options to do this. My current notebook is here, with the plotting cells deliberately broken (though my network layout doesn’t work as yet).

Best,
Simon

Hi Simon,

As luck would have it, we’ve just launched the mutable keyword, which should help you organize your cells in a way that doesn’t cause your graphics to update more frequently than you need them to. For the details, see the introductory notebook:

https://beta.observablehq.com/@jashkenas/introduction-to-mutable-state

I’d recommend pushing your links onto a mutable array as you yield them, then setting a mutable ready = false cell to true when you want to start your rendering. Your visualizations can then depend directly on ready to kick themselves off, and can read from mutable links without depending on them.

If that doesn’t make sense, let me know, and I can try to fork your notebook…

1 Like

Dear Jeremy,

Lucky indeed! Your tip seemed to work - fixed notebook here:

https://beta.observablehq.com/@sdwfrost/distance-calculation-with-tn93-js

Thanks a million
Simon