inulax createStore,dispatch API兼容redux

This commit is contained in:
huangxuan 2023-12-05 19:57:54 +08:00
parent 22036bc75d
commit e31cf7295d
No known key found for this signature in database
GPG Key ID: E79F50C67022565D
1 changed files with 5 additions and 0 deletions

View File

@ -91,6 +91,10 @@ function mergeData(state, data) {
}
export function createStore(reducer: Reducer, preloadedState?: any, enhancers?: StoreEnhancer): ReduxStoreHandler {
if (typeof preloadedState === 'function' && typeof enhancers === 'undefined') {
enhancers = preloadedState;
preloadedState = undefined;
}
const store = createStoreX({
id: 'defaultStore',
state: { stateWrapper: preloadedState },
@ -107,6 +111,7 @@ export function createStore(reducer: Reducer, preloadedState?: any, enhancers?:
return;
} // NOTE: reducer should never return undefined, in this case, do not change state
state.stateWrapper = result;
return action;
},
},
options: {