You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(alternate title: recommended way to do hot module replacement while persisting state?)
I'm trying to get hot module replacement working in my app during development, where I can persist the state of the app between source file edits.
The straightforward way to do this is by updating my init or main to accept an optional initial state and passing in the state from a previous reload if it exists. The issue is that there isn't a convenient way to get the current state of a running app from the "outside" (i.e., the thing that calls main).
What I'm currently doing is using the shutdown callback (which does have access to the model, and can be called from outside) to set a "global" ref, but it feels kinda hacky. An alternative I considered is using pushMsg and having a "give me the current state" message with some external channel to pass the state through, but that also feels unideal, for something that is only really used in development. Or, having each update call set some global ref.
Is there a recommended approach to doing this cleanly? Or maybe if there was a state()/getState()/whatever method that could be called on a running app
The text was updated successfully, but these errors were encountered:
(alternate title: recommended way to do hot module replacement while persisting state?)
I'm trying to get hot module replacement working in my app during development, where I can persist the state of the app between source file edits.
The straightforward way to do this is by updating my
init
ormain
to accept an optional initial state and passing in the state from a previous reload if it exists. The issue is that there isn't a convenient way to get the current state of a running app from the "outside" (i.e., the thing that callsmain
).What I'm currently doing is using the
shutdown
callback (which does have access to the model, and can be called from outside) to set a "global"ref
, but it feels kinda hacky. An alternative I considered is usingpushMsg
and having a "give me the current state" message with some external channel to pass the state through, but that also feels unideal, for something that is only really used in development. Or, having eachupdate
call set some globalref
.Is there a recommended approach to doing this cleanly? Or maybe if there was a
state()
/getState()
/whatever method that could be called on a running appThe text was updated successfully, but these errors were encountered: