Skip to content
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

Can mobx persist state (a la redux)? #390

Closed
tnrich opened this Issue Jul 7, 2016 · 5 comments

Comments

Projects
None yet
5 participants
@tnrich
Copy link

tnrich commented Jul 7, 2016

Hey there,

Just had a question I didn't see an answer to when searching the issues/google: does mobx have a way to persist state between page refreshes like redux devtools persistState functionality?

Thanks!

@mweststrate

This comment has been minimized.

Copy link
Member

mweststrate commented Jul 15, 2016

Hi,

MobX doesn't provide a standard app architecture that prescribes how to organize the state, so the answer is, it depends. If you use a plain object tree it is pretty simple, if you use a plain object graph mobx.toJSON will suffice as well. If you use compex objects (classes / constructores), there is currently the serializr package in development that provides the tools to (de) serialize complex object graphs. But existing ORM libraries might help as well.

Usually setting an efficient serialization mechanism yourself is also not too hard, see for example https://github.com/mobxjs/mobx-reactive2015-demo/blob/master/src/stores/domain-state.js#L46

I hope that helps!

@haikyuu

This comment has been minimized.

Copy link

haikyuu commented Jan 2, 2017

You might want to take a look at https://github.com/AriaFallah/mobx-store.

@sixman9

This comment has been minimized.

Copy link

sixman9 commented May 16, 2018

As of May 2018, it looks like 'mobx-store' has had no updates for 2 years and was archived on Github, so, can I instead suggest:

https://github.com/pinqy520/mobx-persist

@pdeva

This comment has been minimized.

Copy link

pdeva commented Mar 4, 2019

@sixman9 even mobx-persist seems to be dead.
surprising there is no good solutions out there

@mweststrate

This comment has been minimized.

Copy link
Member

mweststrate commented Mar 4, 2019

@pdeva please refrain from comment on issues that are closed for over a year, most people won't see it.

Standardized persisting solutinos are the serializable and mobx-state-tree package. But if you limit your self (like in Redux) to pure data trees to store the data, you don't even need that, and a simple JSON.stringify(state) will do. For further questions, please open a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.