From 7e4155b6a06c30eab9e05bf152ff333827987982 Mon Sep 17 00:00:00 2001 From: Laurent Goudet Date: Fri, 1 Sep 2017 11:14:04 +0200 Subject: [PATCH 1/2] Add meta reducers injection in the Store docs --- docs/store/api.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/store/api.md b/docs/store/api.md index 9143cedbfe..217440bd6b 100644 --- a/docs/store/api.md +++ b/docs/store/api.md @@ -158,3 +158,27 @@ export const reducers: ActionReducerMap = { }) export class FeatureModule { } ``` + +To inject meta reducers, use the `META_REDUCERS` injection token exported in +the Store API and a `Provider` to register the meta reducers through dependency +injection. + +``` +import { MetaReducer, META_REDUCERS } '@ngrx/store'; +import { SomeService } from './some.service'; + +export function getMetaReducers(some: SomeService): MetaReducer[] { + // return array of meta reducers; +} + +@NgModule({ + providers: [ + { + provide: META_REDUCERS, + deps: [SomeService], + useFactory: getMetaReducers + } + ] +}) +export class AppModule {} +``` From 89a864d0145eece2f421397a72181d82fd405c3f Mon Sep 17 00:00:00 2001 From: Laurent Goudet Date: Fri, 1 Sep 2017 14:49:07 +0200 Subject: [PATCH 2/2] Split doc into its own section --- docs/store/README.md | 1 + docs/store/api.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/store/README.md b/docs/store/README.md index 3f90a4d38e..e9949299a0 100644 --- a/docs/store/README.md +++ b/docs/store/README.md @@ -117,6 +117,7 @@ export class MyAppComponent { - [Action Reducers](./actions.md#action-reducers) - [Injecting reducers](./api.md#injecting-reducers) - [Meta-Reducers/Enhancers](./api.md#meta-reducers) +- [Injecting Meta-Reducers](./api.md#injecting-meta-reducers) - [Providing initial state](./api.md#initial-state) - [State composition through feature modules](./api.md#feature-module-state-composition) - [State selectors](./selectors.md) diff --git a/docs/store/api.md b/docs/store/api.md index 217440bd6b..f855d583c4 100644 --- a/docs/store/api.md +++ b/docs/store/api.md @@ -159,6 +159,8 @@ export const reducers: ActionReducerMap = { export class FeatureModule { } ``` +## Injecting Meta-Reducers + To inject meta reducers, use the `META_REDUCERS` injection token exported in the Store API and a `Provider` to register the meta reducers through dependency injection.