offline-mobx.mo
Last updated
Last updated
If you want to make your application work offline, you'll need to check that
Your application has to be used in a low connectivity context (abroad, far from towns, in the subway, in Darius's house, ...)
Control points
Create a connectivity store
Control points
Control points
Define what call you want to make work offline
Store the payload to your application state as pending
Persist it
Whenever there is something stored as pending in your store, display a warning message to the user to let him know
When he wants to, let him do the call again with the stored payload
Clear the pending observable when your call is succesful
In your offline store:
In your component
We implemented a working example of it @BAM, let me know if you want to know more about it.
Control points
Define what call you want to make work offline
Store the payload to your application state as pending
Persist it
Whenever there is something stored as pending in your store display a discret message/icon to the user to let him know
When you get online again (you can use your connectivity observable) try to do the call again
Define a fail detection strategy (for instance after n tries, decide that the called is failed and rollback the state modification you made)
There are ways to check user's connectivity by pinging one of your own server routes instead of basing it on the phone self awareness of its connectivity.
We did not implement offline calls that would need conflict management (several users able to access the same data at the same time) yet.
Here we will do it by ourselves by using AsyncStorage
, you can refer to this to know how to use AsyncStorage
You can also use but in my experience, it's not simpler.
In order to be able to detect this, you can use the react-native's function to get the connectivity status your phone thinks it has.