Mobx-state-tree: [Question] How to implement offline state management like redux-offline?

Created on 29 Nov 2017  路  10Comments  路  Source: mobxjs/mobx-state-tree

I'm a beginner using mobx and my question is if is there something like redux-offline to be possible to use or make with mobx-state-tree ? I know that exists mobx-persist, but it is more like the redux-persist counterpart.

Explaining a bit more:

Right now I'm beginning a project with offline requirements and using redux-offline to get this part done. But I'm really desiring to replace redux to mobx-state-tree (just discovery about it some days ago) to simplifies my workflow and state management (and maybe performance in the future). Since my project is in initial phases, the codebase isn't large, so a port this time is easy.

Thanks in advance.

Most helpful comment

@aislanmaia The goal of this library is to provide the core tools that make it possible to build libraries like this. For example onAction allows recording actions, and powerful middlewares can be build that do for example atomic updates, or optimistic updates etc etc. However, providing these functionalities on top of MST is hopefully done by the community :)

All 10 comments

In MST there is getSnapshot and applySnapshot, so basically you just need to localStorage.setItem("store", getSnapshot(store))
There is no lib yet, and theorically it would be just an overkill I think
In the todos example there is a sample implementation of that :)

Thanks @mattiamanzati . My question here is because the functionalities that we have in redux-offline, such as actions that get queued when offline and dispatched when back online, retry and discard strategies, replacement of persistence mechanism, watcher of network status, centralized configs, and so on. Anyway, thanks again for your reply.

Oh, didnt noticed this functionalities! Btw should be doable with may as well, and theorically redux-offline should work with MST as well, there is no dedicated library yet :)

@aislanmaia The goal of this library is to provide the core tools that make it possible to build libraries like this. For example onAction allows recording actions, and powerful middlewares can be build that do for example atomic updates, or optimistic updates etc etc. However, providing these functionalities on top of MST is hopefully done by the community :)

Thanks for explaining me it @mweststrate . Thats is what I'm thinking about after all. Maybe with free time and more experience with mobx projects, I can bring something to table, but this will require more time and exploration. mobx-state-tree seems to offer all or almost all the base foundations.

Oh @mattiamanzati can u talk a bit more how can this be done, at least theorically? (redux-offline + mst) This could be interesting to learn.

Hi @aislanmaia , have you find a way to fix your issue?

Hey @leedstyh , since I've chosen to follow the redux path to handle that stuff in my project, I haven't time enough to exploring and build something with mobx-state-tree yet to satisfy the offline requirements.

@aislanmaia @leedstyh maybe this would work? https://gist.github.com/benjick/c48dd2db575e79c7b0b1043de4556ebc

@ccfiel not really, the real need is described here by @aislanmaia

I'm also looking or an offline state management solution, any news here? :)

Someone mentioned using redux-offline, is it really possible without a lot of hacking?

Was this page helpful?
0 / 5 - 0 ratings