@@ -13,13 +13,15 @@ import {
13
13
StoreFeature ,
14
14
InitialState ,
15
15
} from './models' ;
16
- import { combineReducers } from './utils' ;
16
+ import { compose , combineReducers , createReducerFactory } from './utils' ;
17
17
import {
18
18
INITIAL_STATE ,
19
19
INITIAL_REDUCERS ,
20
20
REDUCER_FACTORY ,
21
+ _REDUCER_FACTORY ,
21
22
STORE_FEATURES ,
22
23
_INITIAL_STATE ,
24
+ META_REDUCERS ,
23
25
} from './tokens' ;
24
26
import { ACTIONS_SUBJECT_PROVIDERS , ActionsSubject } from './actions_subject' ;
25
27
import {
@@ -62,6 +64,7 @@ export class StoreFeatureModule implements OnDestroy {
62
64
export type StoreConfig < T , V extends Action = Action > = {
63
65
initialState ?: InitialState < T > ;
64
66
reducerFactory ?: ActionReducerFactory < T , V > ;
67
+ metaReducers ?: ActionReducer < T , V > [ ] ;
65
68
} ;
66
69
67
70
@NgModule ( { } )
@@ -89,11 +92,20 @@ export class StoreModule {
89
92
? { provide : INITIAL_REDUCERS , useExisting : reducers }
90
93
: { provide : INITIAL_REDUCERS , useValue : reducers } ,
91
94
{
92
- provide : REDUCER_FACTORY ,
95
+ provide : META_REDUCERS ,
96
+ useValue : config . metaReducers ? config . metaReducers : [ ] ,
97
+ } ,
98
+ {
99
+ provide : _REDUCER_FACTORY ,
93
100
useValue : config . reducerFactory
94
101
? config . reducerFactory
95
102
: combineReducers ,
96
103
} ,
104
+ {
105
+ provide : REDUCER_FACTORY ,
106
+ deps : [ _REDUCER_FACTORY , META_REDUCERS ] ,
107
+ useFactory : createReducerFactory ,
108
+ } ,
97
109
ACTIONS_SUBJECT_PROVIDERS ,
98
110
REDUCER_MANAGER_PROVIDERS ,
99
111
SCANNED_ACTIONS_SUBJECT_PROVIDERS ,
@@ -130,6 +142,7 @@ export class StoreModule {
130
142
reducerFactory : config . reducerFactory
131
143
? config . reducerFactory
132
144
: combineReducers ,
145
+ metaReducers : config . metaReducers ? config . metaReducers : [ ] ,
133
146
initialState : config . initialState ,
134
147
} ,
135
148
} ,
0 commit comments