-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hot State Reloading + MobX? #535
Comments
Sounds like it could be integrated with anything that supports serializing the state? Whether that works for a MobX question can not be answered generically; some MobX encode their entire state in a single state, some don't. An example where it is done with HMR can be found here: https://github.com/mobxjs/mobx-reactive2015-demo I am by the way working on a standardized state container which could easily support this, although that is still experimental and not finished (https://github.com/mweststrate/mobx-state-tree) |
@mweststrate i'm pretty interested in your solution with opinionated state tree, how can i help you with it ? |
@ochervak at this point any feedback on the api is very useful, a good starting point is https://github.com/mweststrate/mobx-state-tree/blob/master/src/inode.ts and the static methods here https://github.com/mweststrate/mobx-state-tree/blob/master/src/node.ts#L189. Probably it is a bit too vague still atm, but the idea is that
I'm currently writing the handler for plain objects, after that arrays, maps and complex objects should be added with a similar pattern |
@aleclarson, that approach in the article isn't suitable for most of cases, even though it's simple and would help to avoid side effects. Let's say we have that counter example. Increment the counter 2 times, then you changed the increment action (reducer): increment (state, payload) {
- return { count: ++state.count }
+ return { count: state.count + 10 }
} The HSR refreshes the webpage and gives you the previous state The reason why it works with Redux DevTools is that it recomputes the reducers, and actually we don't need that state HSR provides at all. Mobx Remotedev could recompute the actions as well, the problem is only with nested changes, which zalmoxisus/mobx-remotedev#5 would handle. |
Closing, as within the MobX package itself there won't be a generic solution. |
Explained in this article.
@mweststrate Could HSR be integrated into MobX? Curious about your thoughts on this.
The text was updated successfully, but these errors were encountered: