[inulax] 修复状态管理器createStore传入enhancer不生效的问题
This commit is contained in:
parent
e7dfd1b7e5
commit
c2c794e023
|
@ -133,12 +133,14 @@ export function createStore(reducer: Reducer, preloadedState?: any, enhancers?:
|
||||||
dispatch: store.$a.dispatch,
|
dispatch: store.$a.dispatch,
|
||||||
};
|
};
|
||||||
|
|
||||||
enhancers && enhancers(result);
|
|
||||||
|
|
||||||
result.dispatch({ type: 'InulaX' });
|
result.dispatch({ type: 'InulaX' });
|
||||||
|
|
||||||
store.reduxHandler = result;
|
store.reduxHandler = result;
|
||||||
|
|
||||||
|
if (typeof enhancers === 'function') {
|
||||||
|
return enhancers(createStore)(reducer, preloadedState);
|
||||||
|
}
|
||||||
|
|
||||||
return result as ReduxStoreHandler;
|
return result as ReduxStoreHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,12 +192,12 @@ export function bindActionCreators(actionCreators: ActionCreators, dispatch: Dis
|
||||||
return boundActionCreators;
|
return boundActionCreators;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compose(...middlewares: ReduxMiddleware[]) {
|
export function compose<T = StoreCreator>(...middlewares: ((...args: any[]) => any)[]): (...args: any[]) => T {
|
||||||
return (store: ReduxStoreHandler, extraArgument: any) => {
|
return (...args) => {
|
||||||
let val;
|
let val: any;
|
||||||
middlewares.reverse().forEach((middleware: ReduxMiddleware, index) => {
|
middlewares.reverse().forEach((middleware, index) => {
|
||||||
if (!index) {
|
if (!index) {
|
||||||
val = middleware(store, extraArgument);
|
val = middleware(...args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
val = middleware(val);
|
val = middleware(val);
|
||||||
|
|
Loading…
Reference in New Issue