@reduxjs/toolkit#compose JavaScript Examples
The following examples show how to use
@reduxjs/toolkit#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 discovery-mobile-ui with MIT License | 5 votes |
createStore = (authentication) => {
const { baseUrl, tokenResponse: { accessToken, idToken } } = authentication;
const fhirClient = new FhirClient(baseUrl, accessToken, idToken);
const epicMiddleware = createEpicMiddleware({
dependencies: {
fhirClient,
},
});
const { patientId } = fhirClient;
const rootReducer = combineReducers({
resources: flattenedResourcesReducer,
associations: associationsReducer,
activeCollectionId: activeCollectionIdReducer,
collections: collectionsReducer,
creatingCollection: isCreatingNewCollectionReducer,
});
const persistReducerConfig = {
version: '0.1.0',
key: `root-${patientId}`,
storage: AsyncStorage,
whitelist: ['activeCollectionId', 'collections', 'creatingCollection'],
};
const store = configureStore({
reducer: persistReducer(persistReducerConfig, rootReducer),
middleware: compose([
thunk,
epicMiddleware,
// routerMiddleware(history), // < e.g.: other middleware
]),
devTools: {
serialize: true, // See: https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize
},
});
epicMiddleware.run(rootEpic);
const callback = () => {
// callback function will be called after rehydration is finished.
};
const persistConfig = {
// manualPersist: true,
};
const persistor = persistStore(store, persistConfig, callback);
return {
store,
persistor,
};
}