Merge branch 'enhancer' into return-to-ts

This commit is contained in:
Yanick Champoux 2021-10-18 08:00:56 -04:00
commit 85e478c02f

View File

@ -322,7 +322,10 @@ export class Updux {
}; };
} }
createStore(initial?: unknown) { createStore(initial?: unknown, enhancerGenerator?: Function) {
const enhancer = (enhancerGenerator ?? applyMiddleware)(this.middleware);
const store : { const store : {
getState: Function & Record<string,Function>, getState: Function & Record<string,Function>,
dispatch: Function & Record<string,Function>, dispatch: Function & Record<string,Function>,
@ -331,7 +334,7 @@ export class Updux {
} = reduxCreateStore( } = reduxCreateStore(
this.reducer, this.reducer,
initial ?? this.initial, initial ?? this.initial,
applyMiddleware(this.middleware) enhancer
) as any; ) as any;
store.actions = this.actions; store.actions = this.actions;