Integrating with Redux/Redux Saga
WARNING: When the following steps are not properly done, expect to experience ModelNotReduxInitializedError and ModelNotSagaInitializedError during development.
Before you can use a model in your components, you have to hook its model's reducers into redux. The same applies for hooking the model's effects into redux-saga. For such do:
import {
combineModelReducers,
modelRootSaga,
} from 'redux-data-model';
import createSagaMiddleware from 'redux-saga';
import {
applyMiddleware,
combineReducers,
createStore,
} from 'redux';
import {modelA, modelB} from './models';
const sagaMiddleware = createSagaMiddleware();
const store = createStore(combineReducers({
...combineModelReducers([modelA, modelB]),
}), applyMiddleware(sagaMiddleware));
sagaMiddleware.run(() => modelRootSaga([modelA, modelB]));
For more info on the API required for setting redux and saga up, see combineModelReducers and modelRootSaga.