A redux module for storing online/offline state in your store.
NOTE: only works in the browser, no React Native implementation provided
It can be installed as an npm package:
$ npm install --save redux-connection-status
The minimal example:
// add the reducer to your storeconst store =// keep connection status and state.connection in sync// from now on you can use store.getState().connection.isOnline in your app
This function has a second optional parameter. The default implementation uses the
navigator.onLine property and
offline events to detect the connection state. You can override this behavior by providing another function. Your function will have access to the store as the first parameter and will be called once on init.
If you detect a change, just call the corresponding action:
const isOnline = falsestore