redux#compose JavaScript Examples
The following examples show how to use
redux#compose.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js From fhir-app-starter with MIT License | 6 votes |
export default function configureStore(initialState = {}, history) {
let composeEnhancers = compose;
const reduxSagaMonitorOptions = {};
// If Redux Dev Tools and Saga Dev Tools Extensions are installed, enable them
/* istanbul ignore next */
if (process.env.NODE_ENV !== 'production' && typeof window === 'object') {
/* eslint-disable no-underscore-dangle */
if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({});
// NOTE: Uncomment the code below to restore support for Redux Saga
// Dev Tools once it supports redux-saga version 1.x.x
// if (window.__SAGA_MONITOR_EXTENSION__)
// reduxSagaMonitorOptions = {
// sagaMonitor: window.__SAGA_MONITOR_EXTENSION__,
// };
/* eslint-enable */
}
const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
// Create the store with two middlewares
// 1. sagaMiddleware: Makes redux-sagas work
// 2. routerMiddleware: Syncs the location/URL path to the state
const middlewares = [sagaMiddleware, routerMiddleware(history), logger];
const enhancers = [applyMiddleware(...middlewares)];
const store = createStore(rootReducer, initialState, composeEnhancers(...enhancers));
// Extensions
store.runSaga = sagaMiddleware.run;
store.runSaga(sagas);
return store;
}
Example #2
Source File: store.js From react-firebase-admin with MIT License | 6 votes |
configureStore = initialState => {
const middlewares = [];
const composeEnhancers =
(process.env.NODE_ENV === 'development'
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
: null) || compose;
middlewares.push(applyMiddleware(thunk));
const store = createStore(
rootReducer,
initialState,
composeEnhancers(...middlewares)
);
store.dispatch(verifyAuth());
const persistor = persistStore(store);
return { store, persistor };
}
Example #3
Source File: index.js From defizap-frontend with GNU General Public License v2.0 | 6 votes |
configureStore = (initialState, history) => {
const middlewares = [thunk, routerMiddleware(history)];
const storeEnhancers = [];
const isDev = process.env.NODE_ENV !== 'production';
if (isDev) {
// allow devs to use their own plugged in browser redux dev tool instead of the builtin component
const devTools = DevTools();
const devToolsEnhancer = window.__REDUX_DEVTOOLS_EXTENSION__
? window.__REDUX_DEVTOOLS_EXTENSION__()
: devTools.instrument();
storeEnhancers.push(devToolsEnhancer);
}
const middlewareEnhancer = applyMiddleware(...middlewares);
storeEnhancers.unshift(middlewareEnhancer);
const store = createStore(
rootReducer(history),
initialState,
compose(...storeEnhancers)
);
if (isDev && module.hot && module.hot.accept) {
module.hot.accept('../reducers', () => {
const nextRootReducer = lazy(() => import('../reducers'));
store.replaceReducer(nextRootReducer);
});
}
return store;
}
Example #4
Source File: index.js From Spoke with MIT License | 6 votes |
constructor(history, initialState = {}) {
const reducer = combineReducers({
...reducers,
apollo: ApolloClientSingleton.reducer(),
routing: routerReducer
});
this.data = createStore(
reducer,
initialState,
compose(
applyMiddleware(
routerMiddleware(history),
ApolloClientSingleton.middleware(),
ReduxThunk.withExtraArgument(ApolloClientSingleton)
),
typeof window === "object" &&
typeof window.devToolsExtension !== "undefined"
? window.devToolsExtension()
: f => f
)
);
}
Example #5
Source File: store.js From OSC-Legal with MIT License | 6 votes |
export default function configureStore(initialState) {
// const epicMiddleware = createEpicMiddleware(rootEpic);
const bundle = compose(applyMiddleware(thunkMiddleware));
const createStoreWithMiddleware = bundle(createStore);
const store = createStoreWithMiddleware(
reducers,
initialState,
window.devToolsExtension ? window.devToolsExtension() : f => f
);
return store;
}
Example #6
Source File: configureStore.js From HexactaLabs-NetCore_React-Initial with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #7
Source File: configureStore.js From dexwebapp with Apache License 2.0 | 6 votes |
// Setting preloadedState is still behind setting initState in each reducer
export default function configureStore(preloadedState) {
const composeEnhancer =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
createRootReducer(history),
preloadedState,
composeEnhancer(
applyMiddleware(
thunk,
routerMiddleware(history),
trackingMiddleware(tracker)
)
)
);
// Hot reloading
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
store.replaceReducer(createRootReducer(history));
});
}
return store;
}
Example #8
Source File: configureStore.js From HexactaLabs-NetCore_React-Level2 with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
productType,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #9
Source File: configureStore.js From sampo-ui with MIT License | 6 votes |
export default function configureStore (preloadedState) {
const epicMiddleware = createEpicMiddleware()
const middlewares = [epicMiddleware]
// https://github.com/zalmoxisus/redux-devtools-extension#11-basic-store
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const composedEnhancers = composeEnhancers(
applyMiddleware(...middlewares)
// other store enhancers could be added here
)
const store = createStore(reducer, preloadedState, composedEnhancers)
epicMiddleware.run(rootEpic)
bindActionCreators(toastrActions, store.dispatch)
return store
}
Example #10
Source File: store.js From tomato-food-delivery with Apache License 2.0 | 6 votes |
store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__()) ||
compose
)
)
Example #11
Source File: index.js From scalable-form-platform with MIT License | 6 votes |
constructor(...args) {
super(...args);
this.state = {};
this.namespace = util.getRandomString(8);
this.store = createStore(
combineReducers(xformBuilderReducer),
compose(applyMiddleware(thunkMiddleware))
);
}
Example #12
Source File: configureStore.dev.js From Lambda with MIT License | 6 votes |
export default function configureStore(history) {
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const enhancer = composeEnhancers(
applyMiddleware(thunk, routerMiddleware(history))
);
const store = createStore(root, enhancer);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept("./rootReducer", () => {
const nextRootReducer = require("./rootReducer").default;
store.replaceReducer(nextRootReducer);
});
}
return store;
}
Example #13
Source File: configureStore.dev.js From Learning-Redux with MIT License | 6 votes |
configureStore = (preloadedState) => {
const store = createStore(
rootReducer,
preloadedState,
compose(applyMiddleware(thunk, api, createLogger()), DevTools.instrument())
);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept("../reducers", () => {
const nextRootReducer = require("../reducers").default;
store.replaceReducer(nextRootReducer);
});
}
return store;
}
Example #14
Source File: configureStore.js From websocket-demo with MIT License | 6 votes |
export default function configureStore(preloadedState) {
const middlewares = [thunkMiddleware];
const middlewareEnhancer = applyMiddleware(...middlewares);
const enhancers = [middlewareEnhancer];
const composedEnhancers = compose(...enhancers);
const store = createStore(reducer, preloadedState, composedEnhancers);
return store;
}
Example #15
Source File: configureStore.js From strapi-plugin-config-sync with MIT License | 6 votes |
configureStore = () => {
const initialStoreState = Map();
const enhancers = [];
const middlewares = [
thunkMiddleware,
];
let devtools;
if (__DEBUG__) {
devtools = (
typeof window !== 'undefined'
&& typeof window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ === 'function'
&& window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ actionsBlacklist: [] })
);
if (devtools) {
console.info('[setup] ✓ Enabling Redux DevTools Extension');
}
}
const composedEnhancers = devtools || compose;
const storeEnhancers = composedEnhancers(
applyMiddleware(...middlewares),
...enhancers,
);
const store = createStore(
rootReducer,
initialStoreState,
storeEnhancers,
);
return store;
}
Example #16
Source File: configureStore.dev.js From djact with MIT License | 6 votes |
export default function configureStore(initialState) {
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; // add support for Redux dev tools
return createStore(
rootReducer,
initialState,
composeEnhancers(applyMiddleware(thunk, reduxImmutableStateInvariant()))
);
}
Example #17
Source File: store.js From ship with MIT License | 6 votes |
store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__()) ||
compose
)
)
Example #18
Source File: store.js From substrate-authn-faucet-frontend with GNU General Public License v3.0 | 6 votes |
configureStore = () => {
const middlewares = Array.prototype.concat(
[],
[thunk, routerMiddleware(history)],
process.env.NODE_ENV === 'development' ? [createLogger()] : []
);
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const enhancer = composeEnhancers(
applyMiddleware(...middlewares),
responsiveStoreEnhancer
);
store = createStore(resetEnhancer(createReducer(history)), enhancer);
store.asyncReducers = {};
return {
store,
history
};
}
Example #19
Source File: store.js From Agaave-frontend with MIT License | 6 votes |
export function configureStore(initialState) {
const store = createStore(
reducers,
initialState,
compose(applyMiddleware(...middlewares))
);
sagaMiddleware.run(sagas);
if (module.hot) {
module.hot.accept('./reducers', () => {
const nextRootReducer = require('./reducers');
store.replaceReducer(nextRootReducer);
});
}
return store;
}
Example #20
Source File: index.js From React-Nest-Admin with MIT License | 6 votes |
export default function configureStore() {
const middlewares = [ReduxThunk, routerMiddleware(history)];
const enhancers = [applyMiddleware(...middlewares)];
// use redux devtool, redux-thunk middleware
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
connectRouter(history)(persistedReducer),
composeEnhancers(...enhancers)
);
const persistor = persistStore(store);
return { store, persistor };
}
Example #21
Source File: configureStore.js From website with MIT License | 6 votes |
export function createApplicationStore(reducers, middleware, initialData = {}) {
const createStoreWithMiddleware = compose(
applyMiddleware(...middleware),
devToolsShouldLoad ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f
)(createStore);
const store = createStoreWithMiddleware(reducers, initialData);
return store;
}
Example #22
Source File: configure-store.js From sailplane-web with GNU General Public License v3.0 | 6 votes |
// if (__DEV__) {
// const logger = createLogger();
// middleware.push(logger);
// }
export default function configureStore(initialState) {
const store = compose(applyMiddleware(...middleware))(createStore)(
persistedReducer,
);
const persistor = persistStore(store);
return {store, persistor};
}
Example #23
Source File: configureStore.dev.js From ThreatMapper with Apache License 2.0 | 6 votes |
export default function configureStore() {
/* eslint-disable no-underscore-dangle */
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
/* eslint-enable */
const store = createStore(
rootReducer,
initialState,
composeEnhancers(applyMiddleware(thunkMiddleware)),
);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers/root', () => {
const nextRootReducer = require('../reducers/root').default;
store.replaceReducer(nextRootReducer);
});
}
return store;
}
Example #24
Source File: store.js From react-03.03 with MIT License | 6 votes |
function initStore() {
const initialStore = {};
const composeEnhancers = (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;
const store = createStore(
// persistReducer(persistConfig, initReducer(history)),
initReducer(history),
initialStore,
composeEnhancers(
applyMiddleware(
reduxThunk,
routerMiddleware(history),
...middlewares
),
)
);
// const persistor = persistStore(store);
// return {store, persistor};
return store;
}
Example #25
Source File: store.js From react-14.01 with MIT License | 6 votes |
function initStore() {
const innitialStore = {};
const store = createStore(
persistReducer(persistConfig, initReducers(history)),
innitialStore,
compose(
applyMiddleware(routerMiddleware(history), ...middlewares),
window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : () => {},
),
);
const persistor = persistStore(store);
return { store, persistor };
}
Example #26
Source File: store.js From react-invenio-deposit with MIT License | 6 votes |
export function configureStore(appConfig) {
const { record, preselectedCommunity, files, config, permissions, ...extra } =
appConfig;
// when not passed, make sure that the value is `undefined` and not `null`
const _preselectedCommunity = preselectedCommunity || undefined;
const initialDepositState = {
record,
editorState: computeDepositState(record, _preselectedCommunity),
config,
permissions,
actionState: null,
actionStateExtra: {},
};
const preloadedState = {
deposit: initialDepositState,
files: preloadFiles(files || {}),
};
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
return createStore(
rootReducer,
preloadedState,
composeEnhancers(
applyMiddleware(thunk.withExtraArgument({ config, ...extra }))
)
);
}
Example #27
Source File: redux.js From makerverse with GNU General Public License v3.0 | 6 votes |
// This is pretty ugly. The CNCjs app had a concept of a "store," then Redux was added.
// The two should be unufied.
export default function configureStore(history, initialState) {
OidcClient.Log.logger = console;
OidcClient.Log.level = OidcClient.Log.DEBUG;
const middleware = [];
const rootReducer = combineReducers({
...reducers,
oidc: Oidc.reducer,
});
const enhancers = [];
const store = createStore(
rootReducer,
initialState,
compose(applyMiddleware(...middleware), ...enhancers)
);
return store;
}
Example #28
Source File: configureStore.js From HexactaLabs-NetCore_React-Final with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
product,
productType,
store
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
...enhancers
)
);
}
Example #29
Source File: configureStore.js From HexactaLabs-NetCore_React-Level1 with Apache License 2.0 | 6 votes |
export default function configureStore(history, initialState) {
const reducers = {
form: formReducer,
router: connectRouter(history),
auth,
home,
provider,
producttype,
store,
};
const middleware = [thunk, routerMiddleware(history)];
const enhancers = [];
// eslint-disable-next-line no-undef
const isDevelopment = process.env.NODE_ENV === "development";
if (
isDevelopment &&
typeof window !== "undefined" &&
window.devToolsExtension
) {
enhancers.push(window.devToolsExtension());
}
const rootReducer = combineReducers(reducers);
return createStore(
rootReducer,
initialState,
compose(applyMiddleware(...middleware), ...enhancers)
);
}