Skip to content

Commit a82f675

Browse files
laurentgoudetbrandonroberts
authored andcommitted
chore(docs): Add meta reducers injection in the Store docs (#341)
1 parent 870a73d commit a82f675

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

docs/store/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export class MyAppComponent {
117117
- [Action Reducers](./actions.md#action-reducers)
118118
- [Injecting reducers](./api.md#injecting-reducers)
119119
- [Meta-Reducers/Enhancers](./api.md#meta-reducers)
120+
- [Injecting Meta-Reducers](./api.md#injecting-meta-reducers)
120121
- [Providing initial state](./api.md#initial-state)
121122
- [State composition through feature modules](./api.md#feature-module-state-composition)
122123
- [State selectors](./selectors.md)

docs/store/api.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,29 @@ export const reducers: ActionReducerMap<fromFeature.State> = {
158158
})
159159
export class FeatureModule { }
160160
```
161+
162+
## Injecting Meta-Reducers
163+
164+
To inject meta reducers, use the `META_REDUCERS` injection token exported in
165+
the Store API and a `Provider` to register the meta reducers through dependency
166+
injection.
167+
168+
```
169+
import { MetaReducer, META_REDUCERS } '@ngrx/store';
170+
import { SomeService } from './some.service';
171+
172+
export function getMetaReducers(some: SomeService): MetaReducer[] {
173+
// return array of meta reducers;
174+
}
175+
176+
@NgModule({
177+
providers: [
178+
{
179+
provide: META_REDUCERS,
180+
deps: [SomeService],
181+
useFactory: getMetaReducers
182+
}
183+
]
184+
})
185+
export class AppModule {}
186+
```

0 commit comments

Comments
 (0)