Is it possible to create offline first apps with React
From what I've understood offline first apps need a way to tell if the user is connected; if not, it stores changes locally and syncs with the remote server when online.
The way I've found to do this with web apps is by using pouchdb on the client communicating with an api connected to a couchdb database. Or by using Firebase.
Is it possible to have similar functionality using React-Native? Maybe by using the pouchdb-async-storage adapter. Are there other alternatives out there for local-remote data syncing?
I build an AsycStorage Adapter for PouchDB, including Polyfills for React-native. Properly that helps.
asyncstorage adapter for PouchDB
I haven't actually implemented offline capabilities in a React-Native app but from looking at the docs, the APIs provided enable you to do so.
The APIs you're looking for are AsyncStorage (for data persistence) and to detect the connection info use NetInfo.
You're on the right track about using pouchdb. The part you will most likely have to write yourself is the syncing script (I'm not sure you can do this in the background but I may be wrong).
Let me know how you get on or if you want to discuss further @hugo__df on twitter :)
pouchdb-react-native是一个很好的解决方案
链接地址: http://www.djcxy.com/p/41184.html