How to use the redux.compose.apply function in redux

To help you get started, we’ve selected a few redux 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 TrueCar / gluestick / src / shared / lib / createStore.js View on Github external
export default function (customRequire, hotCallback, devMode) {
  const reducer = combineReducers(Object.assign({}, {_gluestick}, customRequire()));
  const composeArgs = [
    applyMiddleware(promiseMiddleware, thunk)
  ];

  // Include dev tools only if we are in development mode
  if (devMode) {
    composeArgs.push(DevTools.instrument());
  }

  const finalCreateStore = compose.apply(null, composeArgs)(createStore);
  const store = finalCreateStore(reducer, typeof window !== "undefined" ? window.__INITIAL_STATE__ : {});

  if (hotCallback) {
    hotCallback(() => {
      const nextReducer = combineReducers(Object.assign({}, {_gluestick}, customRequire()));
      store.replaceReducer(nextReducer);
    });
  }

  return store;
}
github antitoxic / mobx-redux-devtools / src / devtools.js View on Github external
function getStoreAndDevTools(props) {
    const {observable, hydrate, serialize, enhancers, children} = props;
    for (let i = 0; i < devtoolRegistry.length; i++) {
        let registration = devtoolRegistry[i];
        // one observable can only have 1 devtool enabled
        if (registration.observable == observable) {
            return registration.result;
        }
    }
    const ReduxDevTools = createDevTools(
        
                     {children}
        
    );
    const enhancer = compose.apply(this, [ReduxDevTools.instrument()].concat(enhancers))
    const store = createStore(function (state={}, action) {
        if (action.type != ActionTypes.MOBX_UPDATE) return state;
        return action.state
    }, serialize(observable), enhancer);
    reaction(() => serialize(observable), state => {
        if (observable.$mobx.fromJS) {
            observable.$mobx.fromJS = false;
            return;
        }
        store.dispatch({type: ActionTypes.MOBX_UPDATE, state})
    });
    const result = [store, ReduxDevTools];
    devtoolRegistry.push({result, observable});
    return result
};
github viniciusdacal / redux-arc / es / policies.js View on Github external
return function (done) {
        var chain = policies.map(function (policy) {
          return policy(store);
        });
        return compose.apply(undefined, chain)(done);
      };
    };
github bananaoomarang / chapters / client / index.jsx View on Github external
const DevTools = createDevTools(
  
    
  
);

let stores = [applyMiddleware(promiseMiddleware)];

if (__DEV__ && __DEVTOOLS__) {
  const { devTools, persistState } = require('redux-devtools');

  stores.push(DevTools.instrument(), persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)));
}

const finalCreateStore = compose.apply(null, stores)(createStore);

const store = finalCreateStore(reducer, initialState);

const routes = createRoutes(function (nextState, transition, done) {
  if(nextState.location.action === 'POP')
      return done();

  const components = nextState.routes.map(route => route.component);

  fetchComponentData(store.dispatch, components, nextState.params)

  return done();
});

if (__DEV__ && __DEVTOOLS__) {
  render(
github zalmoxisus / redux-devtools-extension / npm-package / index.js View on Github external
function() {
      if (arguments.length === 0) return undefined;
      if (typeof arguments[0] === 'object') return compose;
      return compose.apply(null, arguments);
    }
);
github ajainarayanan / react-dag / dag-store.js View on Github external
export default function configureStore(
  data,
  reducersMap,
  middlewares = [],
  enhancers = [],
) {
  let store = createStore(
    combinedReducers(reducersMap),
    data,
    compose.apply(
      null,
      [applyMiddleware.apply(null, middlewares)].concat(
        enhancers.map(enhancer => enhancer()),
      ),
    ),
  );
  return store;
}
github zalmoxisus / redux-devtools-extension / npm-package / logOnly.js View on Github external
exports.composeWithDevTools = function() {
  if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
    if (arguments.length === 0) return enhancer();
    if (typeof arguments[0] === 'object') return composeWithEnhancer(arguments[0]);
    return composeWithEnhancer().apply(null, arguments);
  }

  if (arguments.length === 0) return undefined;
  if (typeof arguments[0] === 'object') return compose;
  return compose.apply(null, arguments);
};
github NoriSte / redux-saga-login-react-example / src / store / configureStore.js View on Github external
export default function configureStore() {
  const sagaMiddleware = createSagaMiddleware()
  const composeArgs = [
    applyMiddleware(sagaMiddleware),
    applyMiddleware(thunk),
  ];
  if(window && window.__REDUX_DEVTOOLS_EXTENSION__) {
    composeArgs.push(window.__REDUX_DEVTOOLS_EXTENSION__());
  }

  const store = createStore(
    rootReducer,
    compose.apply(undefined, composeArgs)
  );

  sagaMiddleware.run(loginFlow);
  sagaMiddleware.run(logActions);

  return store;
}
github zalmoxisus / redux-devtools-extension / npm-package / logOnly.js View on Github external
return function () {
    return compose(compose.apply(null, arguments), enhancer(config));
  }
}