redux-enhancer-react-native-netstate

1.0.1 • Public • Published

redux-enhancer-react-native-netstate

Notify net state changes directly to your Redux store!

Installation

npm install --save redux-enhancer-react-native-netstate

OR

yarn add redux-enhancer-react-native-netstate

Usage

When you create your Redux store, add the enhancer:

import { createStore } from 'redux';
import applyNetStateListener from 'redux-enhancer-react-native-netstate';

...

const store = createStore(reducers, initalState, [
  applyNetStateListener(),
]);

The store will now automatically dispatch net state related actions.

For instance, you can use it in a reducer:

import { ONLINE, OFFLINE } from 'redux-enhancer-react-native-netstate';

function reducer(state = '', action) {
  switch (action.type) {
    case ONLINE:
      return 'app is online';
    case OFFLINE:
      return 'app is offline';    
    default:
      return state
  }
}

/redux-enhancer-react-native-netstate/

    Package Sidebar

    Install

    npm i redux-enhancer-react-native-netstate

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    4.85 kB

    Total Files

    6

    Last publish

    Collaborators

    • deepaksinghbeto
    • thisisjaiswal