Reputation: 1
I'm developing an offline-first webapp (HTML5 & JS) for data collecting which should sync to a MySQL server when online. I also need to get a subset from the MySQL DB to search in offline (selecting categories/attributes for the data collecting).
To summarize things:
I've looked into PouchDB but I don't think it is the right solution because the server side applications all depend on MySQL and it's not an option to rewrite all.
What solution would you suggest?
Upvotes: 0
Views: 1017
Reputation: 646
Let's say you are having JS blogging app with Redux (for example) on top.
Your Data Layer (Redux) persists data into LocalStorage and vice-versa, when app is loaded it checks LocalStorage and if there are data - data loaded into Redux.
Your Redux contains Posts and NewPosts.
When app is online, you send requests to the server, server responds with some data, you store this data into the Posts.
When app is offline you don't send any requests, you just store new posts into the NewPosts.
When your app is back online - you send every item from NewPosts to the server, and if they are successfully stored - remove them from NewPosts and update Posts with new stuff.
In the application you are rendering NewPosts first (probably with not synced icon or something) then Posts after.
Hopefully I understood your question correctly.
Upvotes: 2