Curious: has anyone yet used Hooks to build a state-preserving live editing tool? Reloads are so awful—I'm still hoping for DisplayScript's glorious ability to update the running program on every editor keypress without losing state. :)
Conversation
That was one of the first things I tried :-) Need to get back to it. In general it's much easier to hot reload than classes because wrapping a function is sufficient. A bit harder to detect when to reset (e.g. if order or type changes).
2
11
Right: the ability to swap the function body out but keep the same hook state struck me as promising in the spirit of DisplayScript’s state cells. Here’s hoping!
1
1
Regarding order/type changes: what if the tool embedded a flow server? Would be enough for types but not order. For that you’d want an incremental AST diff—paging
1
1
I think you could solve the reordering problem using flow-parser’s AST output actually (in the common case that lval bindings for calls to hooks stay constant).
DS is robust to those intermediate states by speculatively evaluating each key press and unwinding if needed. So good.


