3.0.0 • Published 7 years ago

redux-online-store-enhancer v3.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

redux-online-store-enhancer

Automatically detect if you are online or online, in a browser or on a native device.

Install

yarn add redux-online-store-enhancer

Browser Example

import onlineStoreEnhancer, { onlineReducer } from 'redux-online-store-enhancer';

const reducer = {
  online: onlineReducer,
};

const middleware = [];
const store = createStore(
  reducer,
  compose(
    applyMiddleware(...middleware),
    onlineStoreEnhancer()
  )
);

// get from state directly
const { online } = store.getState();

// reselect
const selectOffline = (state) => state.online;

React Native Example

import { NetInfo } from 'react-native';
import onlineStoreEnhancer, { onlineReducer } from 'redux-online-store-enhancer';

const reducer = {
  online: onlineReducer,
};

const middleware = [];
const store = createStore(
  reducer,
  compose(
    applyMiddleware(...middleware),
    onlineStoreEnhancer(NetInfo)
  )
);

// get from state directly
const { online } = store.getState();

// reselect
const selectOffline = (state) => state.online;

Global app state now has a top level, online, attribute that will dynamically change as browser goes on and online.

3.0.0

7 years ago

2.0.0

7 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago