Skip to content

Commit

Permalink
fix(@dxjs/core): create reducer 中 enhancer 为空
Browse files Browse the repository at this point in the history
增加默认值
  • Loading branch information
taixw2 committed Apr 16, 2020
1 parent e462a25 commit fc10e63
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/dx/create-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export function createReducer(model: DxModelInterface, inst: symbol): Reducer {
const enhance = store.enhancer.get(inst)!;
const Model = model.constructor;

const modelLabels: string[] = Reflect.getMetadata(LABEL, Model) || [];
const reducerEnhancerFilter = enhance.reducerEnhancer!.filter(
(enhancer: Enhancer<ReducerEnhancer>): boolean => {
const modelLabels: string[] = Reflect.getMetadata(LABEL, Model) ?? [];
const reducerEnhancerFilter =
enhance.reducerEnhancer?.filter((enhancer: Enhancer<ReducerEnhancer>): boolean => {
const _enhancer = enhancer as EnhancerFilter<ReducerEnhancer>;
if (_enhancer.include === '*') {
return true;
Expand All @@ -31,8 +31,7 @@ export function createReducer(model: DxModelInterface, inst: symbol): Reducer {
return !modelLabels.some(label => (_enhancer.exclude as RegExp).test(label));
}
return false;
},
);
}) ?? [];

const reducerEnhancer = reducerEnhancerFilter
.map(
Expand Down

0 comments on commit fc10e63

Please sign in to comment.