You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/store/api.md
+58-4
Original file line number
Diff line number
Diff line change
@@ -43,10 +43,13 @@ export function getInitialState() {
43
43
})
44
44
```
45
45
46
-
## Meta Reducers
46
+
## Meta-reducers
47
47
48
-
@ngrx/store composes your map of reducers into a single reducer. Use the `metaReducers`
49
-
configuration option to provide an array of meta-reducers that are composed from right to left.
48
+
@ngrx/store composes your map of reducers into a single reducer.
49
+
50
+
> Developers can think of meta-reducers as hooks into the action->reducer pipeline. Meta-reducers allow developers to pre-process actions before *normal* reducers are invoked.
51
+
52
+
Use the `metaReducers` configuration option to provide an array of meta-reducers that are composed from right to left.
50
53
51
54
Note: Meta-reducers in NgRx are similar to middleware used in Redux.
52
55
@@ -96,6 +99,56 @@ export class FeatureModule {}
96
99
97
100
The feature state is added to the global application state once the feature is loaded. The feature state can then be selected using the [createFeatureSelector](./selectors.md#createFeatureSelector) convenience method.
98
101
102
+
## Feature Module Reducers and AOT
103
+
104
+
Developers can use:
105
+
*`StoreModule.forFeature(<name>, <reducers map>, { initialState : <reducers initial state map>})`.
Due to AOT constraints, however, the following is not allowed:
109
+
110
+
```console
111
+
StoreModule.forFeature(<name>, combineReducers(<reducers map>, <reducers initial state map>))
112
+
```
113
+
114
+
Since the compiler needs to be able to statically analyze your code, you can’t call functions when defining metadata in the NgModule. In such cases, InjectionTokens are needed (see below):
115
+
116
+
Fortunately - with Feature modules - we can avoid injection tokens using the following approach:
0 commit comments