@sophiebits @dan_abramov @sebmarkbage 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. :)
-
-
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 replies 0 retweets 11 likes -
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 reply 0 retweets 1 like -
Replying to @andy_matuschak @dan_abramov and
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
@rob_rix1 reply 0 retweets 1 like -
Replying to @andy_matuschak @dan_abramov and
Yeah, if you can know which node the keypress is going into you can do a much better job much faster than ex post facto diff reconstruction. tbh tho this is still going to be hard because so many keypresses yield inconsistent states, so maybe you want structural editing?
1 reply 0 retweets 1 like
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.
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.