Skip to content

Commit

Permalink
docs(effects): add documentation for ROOT_EFFECTS_INIT (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored and brandonroberts committed Jul 13, 2018
1 parent 2cb81d8 commit de78141
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/effects/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ Usage:
export class AppModule {}
```

### ROOT_EFFECTS_INIT

After all the root effects have been added, the root effect dispatches a `ROOT_EFFECTS_INIT` action.
You can see this action as a lifecycle hook, which you can use in order to execute some code after all your root effects have been added.

```ts
@Effect()
init$ = this.actions$.pipe(
ofType(ROOT_EFFECTS_INIT),
map(_ => ...)
);
```

### forFeature

Registers @ngrx/effects services to run with your feature modules.
Expand Down Expand Up @@ -73,7 +86,7 @@ export class SomeEffectsClass {

### Non-dispatching Effects

Pass `{ dispatch: false }` to the decorator to prevent dispatching.
Pass `{ dispatch: false }` to the decorator to prevent dispatching.

Sometimes you don't want effects to dispatch an action, for example when you only want to log or navigate. But when an effect does not dispatch another action, the browser will crash because the effect is both 'subscribing' to and 'dispatching' the exact same action, causing an infinite loop. To prevent this, add { dispatch: false } to the decorator.

Expand Down

0 comments on commit de78141

Please sign in to comment.