README
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