redux-middleware-react-native-netinfo

0.0.5 • Public • Published

redux-middleware-react-native-netinfo

license npm version npm downloads Code Climate build

Glue NetInfo from react-native to Redux.

Installation

npm install --save redux-middleware-react-native-netinfo

Usage

// Just import the middleware and add it to your store
import { createStore, applyMiddleware } from 'redux';
import { middleware as netInfo } from 'redux-middleware-react-native-netinfo';
const createStoreWithMiddleware = applyMiddleware(netInfo)(createStore);
 
// And in your reducers receive the value
import { TYPE as NET_INFO } from 'redux-middleware-react-native-netinfo';
 
function netInfoReducer(state = {}, action) {
    switch (action.type) {
        case NET_INFO:
            console.log('NetInfo:', action.payload);
 
        default:
            return state;
    }
}
 

Todo

  • Write tests for everything!

Package Sidebar

Install

npm i redux-middleware-react-native-netinfo

Weekly Downloads

2

Version

0.0.5

License

MIT

Last publish

Collaborators

  • michaelcontento