|
@@ -5,7 +5,7 @@ import {composeReducers} from 'redux-sac';
|
|
|
import {effectsMiddleware} from 'redux-effex';
|
|
|
|
|
|
export default () => {
|
|
|
- let reducers = [], effects = [], middlewares = [];
|
|
|
+ let reducers = [], effects = [], middlewares = [], initialState;
|
|
|
|
|
|
function withReducers (..._reducers) {
|
|
|
reducers.push(..._reducers);
|
|
@@ -22,12 +22,18 @@ export default () => {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ function withInitializers (...initializers) {
|
|
|
+ initialState = initializers.reduce((soFar, each) => each(soFar), initialState);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
function create () {
|
|
|
return createStore(
|
|
|
composeReducers(...reducers),
|
|
|
+ initialState,
|
|
|
applyMiddleware(...middlewares, effectsMiddleware(effects))
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- return {withReducers, withMiddlewares, withEffects, create};
|
|
|
+ return {withReducers, withMiddlewares, withEffects, withInitializers, create};
|
|
|
}
|