redux-middleware-react-native-appstate
v0.0.5 redux redux-middleware middleware react-native fsa flux-standard-action flux
redux-middleware-react-native-appstate
Glue AppState from react-native to Redux.
Installation
npm install --save redux-middleware-react-native-appstate
Usage
// Just import the middleware and add it to your store
import { createStore, applyMiddleware } from 'redux';
import { middleware as appState } from 'redux-middleware-react-native-appstate';
const createStoreWithMiddleware = applyMiddleware(appState)(createStore);
// And in your reducers receive the value
import { TYPE as APP_STATE } from 'redux-middleware-react-native-appstate';
function appStateReducer(state = {}, action) {
switch (action.type) {
case APP_STATE:
console.log('AppState:', action.payload);
default:
return state;
}
}
Todo
Write tests for everything!
npm i redux-middleware-react-native-appstate
Metadata
- MIT
- Whatever
- Michael Contento
- released 11/13/2015