Sebas
Sebas

Reputation: 27

How to catch data on React to send to the server when it reconnects

I've an application in React and Redux who is connected with my server in Sails (Node), this app works fine in online mode (the normal mode) but i want to build an offline mode who can persist or catch the data and when i detect a the connection again send all the data to the main server in the backend, in this case for example i'm working in the online mode within connection with my Server in Node, the cuestion is when i shutdown this server and my app try to work offline, how i can catch or persist the data in the moment when is in offline mode, and send to the server when reconnect?

I'm using React with Redux and Sails (Node), I've tried to use a Local Server and sync the DB of the front and the back but i think isn't secure.

I expect sync the data in my global state in the front with the DB in my main server when the connection with the server is restored

Upvotes: 0

Views: 156

Answers (1)

Arseniy-II
Arseniy-II

Reputation: 9167

Build an offline mode is a complicated thing. That requires a few technologies:

  1. You need to know how to detect offline/online mode
  2. You need to know how to Persist redux state

  3. And you definitely should check what is PWA. Starting from caching files with service workers

Upvotes: 1

Related Questions