How to use the react-native-offline.createNetworkMiddleware function in react-native-offline

To help you get started, we’ve selected a few react-native-offline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Osedea / react-native-offline-first-example / js / store.js View on Github external
// @flow
import { Platform } from 'react-native';
import { composeWithDevTools } from 'remote-redux-devtools';
import { applyMiddleware, createStore } from 'redux';
import Thunk from 'redux-thunk';
import { createNetworkMiddleware } from 'react-native-offline';
import { persistStore, autoRehydrate } from 'redux-persist';
import realmPersist from 'redux-persist-realm';

import reducer from './reducer';

const preloadedState = {};
const networkMiddleware = createNetworkMiddleware();
const composeEnhancers = composeWithDevTools({
    name: Platform.OS,
    hostname: '127.0.0.1',
    port: 8888,
    realtime: true,
});

const store = createStore(
    reducer,
    preloadedState,
    composeEnhancers(
        applyMiddleware(...[
            networkMiddleware,
            Thunk,
        ]),
        autoRehydrate()
github anchetaWern / RNOffline / Root.js View on Github external
createNetworkMiddleware
} from "react-native-offline";

import LoginScreen from "./src/screens/LoginScreen";
import UsersScreen from "./src/screens/UsersScreen";
import ChatScreen from "./src/screens/ChatScreen";

import { Provider } from "react-redux";
import { createStore, combineReducers, applyMiddleware } from "redux";

import ChatReducer from "./src/reducers/ChatReducer";

import { watcherSaga } from "./src/sagas";

const sagaMiddleware = createSagaMiddleware();
const networkMiddleware = createNetworkMiddleware();

const persistConfig = {
  key: "root",
  storage,
  blacklist: ["network", "chat"]
};

const chatPersistConfig = {
  key: "chat",
  storage: storage,
  blacklist: ["isNetworkBannerVisible"]
};

const rootReducer = combineReducers({
  chat: persistReducer(chatPersistConfig, ChatReducer),
  network
github rgommezz / react-native-offline / example / redux / createStore.js View on Github external
export default function createReduxStore({
  withSaga = false,
  queueReleaseThrottle = 1000,
} = {}) {
  const networkMiddleware = createNetworkMiddleware({
    regexActionType: /^OTHER/,
    actionTypes: ['ADD_ONE', 'SUB_ONE'],
    queueReleaseThrottle,
  });

  const sagaMiddleware = createSagaMiddleware();

  const rootReducer = combineReducers({
    counter,
    network,
  });

  const middlewares = [networkMiddleware];
  if (withSaga === true) {
    middlewares.push(sagaMiddleware);
  }

react-native-offline

Handy toolbelt to deal with offline mode in React Native applications. Cross-platform, provides a smooth redux integration.

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis