How to use the @redux-offline/redux-offline.createOffline function in @redux-offline/redux-offline

To help you get started, we’ve selected a few @redux-offline/redux-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 redux-offline / redux-offline / examples / web / client / src / store.js View on Github external
function tickMiddleware(store) {
  return next => action => {
    if (action.type === 'Offline/SCHEDULE_RETRY') {
      const intervalId = setInterval(() => {
        store.dispatch({ type: 'TICK' });
      }, 1000);
      setTimeout(() => clearInterval(intervalId), action.payload.delay);
    }
    return next(action);
  };
}
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

let store;
if (process.env.REACT_APP_OFFLINE_API === 'alternative') {
  const { middleware, enhanceReducer, enhanceStore } = createOffline(config);
  store = createStore(
    enhanceReducer(reducer),
    undefined,
    composeEnhancers(applyMiddleware(middleware, tickMiddleware), enhanceStore)
  );
} else {
  store = createStore(
    reducer,
    composeEnhancers(offline(config), applyMiddleware(tickMiddleware))
  );
}

export default store;
github zzorba / ArkhamCards / app / store.js View on Github external
export default function configureStore(initialState) {
  const offline = createOffline({
    ...offlineConfig,
    persist: false,
  });

  const migrations = {
    0: (state) => {
      const newState = Object.assign({}, state);
      if (newState.weaknesses) {
        delete newState.weaknesses;
      }
      return newState;
    },
  };

  const persistConfig = {
    key: 'persist',

@redux-offline/redux-offline

Redux Offline-First Architecture

MIT
Latest version published 4 years ago

Package Health Score

59 / 100
Full package analysis

Similar packages