123456789101112131415161718192021222324252627282930313233343536373839 |
- "use strict";
- import {createStore, applyMiddleware} from 'redux';
- import {composeReducers} from 'redux-sac';
- import {effectsMiddleware} from 'redux-effex';
- export default () => {
- let reducers = [], effects = [], middlewares = [], initialState;
- function withReducers (..._reducers) {
- reducers.push(..._reducers);
- return this;
- }
- function withEffects (..._effects) {
- effects.push(..._effects);
- return this;
- }
- function withMiddlewares (..._middlewares) {
- middlewares.push(..._middlewares);
- 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, withInitializers, create};
- }
|