react-native-saga-offline

1.1.1007 • Public • Published

react-native-saga-offline

Adds saga actions to offline queue if network is not reachable, dispatch offline actions once network becomes reachable

Installation

npm install --save react-native-saga-offline # with npm
yarn add react-native-saga-offline # with yarn

Link react-native-internet-reachability

react-native link react-native-internet-reachability

How it works

How to use

 
import createSagaOfflineMiddleware, { Connectivity } from 'react-native-saga-offline';
 
 
const sagaOffline = createSagaOfflineMiddleware();
this.store = this.createStore(
      persistedRootReducer,
      applyMiddleware(sagaOffline) // make sure sagaOffline is first middleware to be added
    );
    
new Connectivity(this.store);
 
 

Add reducer

 
import { offlineReducer } from 'react-native-saga-offline';
 
 
const appReducer = combineReducers({
  offline: offlineReducer,
});

Action with meta.retry : true would be queued as offline action

 
export const sagaAction = () => ({
  type: sagaActionsTypes.actionType,
  meta: {
    retry: true,
  },
});

Action from offline queue with have meta.actionFromOfflineQueue as true

Package Sidebar

Install

npm i react-native-saga-offline

Weekly Downloads

2

Version

1.1.1007

License

ISC

Unpacked Size

13.7 kB

Total Files

13

Last publish

Collaborators

  • hardeepsingh