-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add support?! to mobx-state-tree #37
Comments
@pinqy520 I think is worth to add that example to the readme, it will help a lot people. But also the point of my request this is to have the same API, where you can setup the storage you want and the fields of the data structure you want to save by default. Just look how many checks like one https://github.com/mobxjs/mobx-state-tree/blob/master/packages/mst-example-bookshop/src/stores/CartStore.js#L56 is happening. The proposal is to use a common package for this interaction. |
I think I understand your request now, and I will try to support MST when I have time. My job is quite busy, recently. |
@pinqy520 hey man, are you gonna consider to open this issue? |
If it is decided to make this a separate package, I grabbed the npm name |
Found this gist that I might try using: Otherwise, I too would be interested in direct mobx state tree support from this library. |
If anyone's interested, I have a super simple working example repo that includes a helper to initialize the store and configure it for persistence, a way to pass in a default state snapshot for when no persisted state is found, an It's web only, but you can adapt it for React Native by changing |
I haven't used MST, but it looks like you don't really need more than a few lines of code to do this without mobx-persist since MST already handles all the serialization/deserialization. In the egghead video by the MobX creator (Michel Weststrate), it looks extremely straightforward: |
- made a bunch of changes, but works in mostly the same fashion - mostly additions and superificial changes to the underlying code - e.g. whitelists + blacklists (and as arrays, like redux-persist), persist returns promise instead of calling `afterHydration`, etc - wanted lib per pinqy520/mobx-persist#37 , but only gists and examples around - it's a tiny wrapper library for now, but still faster than writing by yourself - installing via GH since empty NPM package is owned by someone else rn - pinqy520/mobx-persist#37 (comment)
- made a bunch of changes, but works in mostly the same fashion - mostly additions and superificial changes to the underlying code - e.g. whitelists + blacklists (and as arrays, like redux-persist), persist returns promise instead of calling `afterHydration`, etc - wanted lib per pinqy520/mobx-persist#37 , but only gists and examples around - it's a tiny wrapper library for now, but still faster than writing by yourself - installing via GH since empty NPM package is owned by someone else rn - pinqy520/mobx-persist#37 (comment)
Hey folks, since there were a bunch of examples here, but no concrete library, I decided to make my own at agilgur5/mst-persist. It takes as inspiration some of the examples here, as well as mobx-persist and redux-persist. I extracted it out of an RN app of mine and it's currently being used in it in production there. It supports whitelists and blacklists out-of-the-box and I'm planning on adding transforms to support some of my own use cases as well. @nickbreaton would appreciate if you could transfer ownership of the NPM package to me so I can publish it under the same name! :) Since the dependencies are different between |
@agilgur5 You should be good to go! 👍 |
Thanks @nickbreaton ! Just published v0.0.1! @pinqy520 or @yordis think we can close this one out now. hope to collaborate more in the future on similar features :) |
@agilgur5 Amazing! |
Any idea how can we use this with mobx-state-tree?
The text was updated successfully, but these errors were encountered: