|
@@ -1,26 +1,10 @@
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
-import EventEmitter from 'event-emitter';
|
|
|
|
import {createStore, applyMiddleware} from 'redux';
|
|
import {createStore, applyMiddleware} from 'redux';
|
|
import {composeReducers} from 'redux-sac';
|
|
import {composeReducers} from 'redux-sac';
|
|
import {effectsMiddleware} from 'redux-effex';
|
|
import {effectsMiddleware} from 'redux-effex';
|
|
-import {persistStore} from 'redux-persist';
|
|
|
|
|
|
|
|
export default () => {
|
|
export default () => {
|
|
- const ee = new EventEmitter();
|
|
|
|
-
|
|
|
|
- function on (event, handler) {
|
|
|
|
- ee.on(event, handler);
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let persistOptions = {};
|
|
|
|
-
|
|
|
|
- function withPersistence (_persistOptions) {
|
|
|
|
- persistOptions = _persistOptions;
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
let reducers = [], effects = [], middlewares = [];
|
|
let reducers = [], effects = [], middlewares = [];
|
|
|
|
|
|
function withReducers (..._reducers) {
|
|
function withReducers (..._reducers) {
|
|
@@ -44,12 +28,8 @@ export default () => {
|
|
applyMiddleware(...middlewares, effectsMiddleware(effects))
|
|
applyMiddleware(...middlewares, effectsMiddleware(effects))
|
|
);
|
|
);
|
|
|
|
|
|
- const persistor = persistStore(store, persistOptions, () => ee.emit('rehydrate', store));
|
|
|
|
-
|
|
|
|
- if (reset) persistor.purge();
|
|
|
|
-
|
|
|
|
return store;
|
|
return store;
|
|
}
|
|
}
|
|
|
|
|
|
- return {withReducers, withMiddlewares, withEffects, withPersistence, on, create};
|
|
|
|
|
|
+ return {withReducers, withMiddlewares, withEffects, create};
|
|
}
|
|
}
|