observablehq / observable-jupyter

This repository has been archived. Please see the fork maintained by Thomas Ballinger.
https://github.com/thomasballinger/observable-jupyter
ISC License
4 stars 0 forks source link

Preserve input states on re-execution #16

Open thomasballinger opened 4 years ago

thomasballinger commented 4 years ago

Right now re-running a Jupyter cell blows away all DOM and we recreate everything. This is a simple model that other Jupyter embeds (like Altair, the Python Vega-lite wrapper library) use.

@jashkenas brought up that if we were to just pass in the data (say, if the only thing changing is inputs={'data': new_data}) and we reused the DOM and Observable runtime, we could reuse slider state! Similar to what radames described on the forums, but better-motivated.

If we could still make this work with all the tricky situations like exported notebooks, it would be a definite improvement any other interactive Jupyter embed. Even is the DOM went away but we could keep the runtime and the module stashed somewhere globally, there would be some benefits.

Possible downside: a less consistent model of state, now that a reload would blow away this state but a full notebook re-execution would not. Maybe full notebook re-executions or kernel restarts are special and do reset slider state since the point if them is often reproducibility.