Usage with Redux
The installation is a bit different if you're already using Redux. Please follow this guide only if you're already using Redux. If you're not please follow the normal installation.
We'll most likely be moving away from a Redux implementation. See here.
Create the data service as you normally…
import { createDataService } from 'resift';
const dataService = createDataService(/* ... */);
export default dataService;
…but instead of adding in the ReSift provider, add the data service as a middleware.
import { createStore, applyMiddleware } from 'redux';
import dataService from './dataService';
import rootReducer from './rootReducer';
const store = createStore(rootReducer, {}, applyMiddleware(dataService));
Lastly, add the reducer dataService
to the root reducer from dataServiceReducer
:
import { dataServiceReducer } from 'resift';
import { combineReducers } from 'redux';
const rootReducer = combineReducers({
// ...
dataService: dataServiceReducer,
// ...
});
export default rootReducer;
That's it!