Skip to content

Commit

Permalink
docs(Effects): add UPDATE_EFFECTS
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Aug 30, 2018
1 parent f05ea92 commit 68f88c7
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/effects/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can see this action as a lifecycle hook, which you can use in order to execu
@Effect()
init$ = this.actions$.pipe(
ofType(ROOT_EFFECTS_INIT),
map(_ => ...)
map(action => ...)
);
```

Expand All @@ -45,6 +45,32 @@ Usage:
export class FeatureModule {}
```

### UPDATE_EFFECTS

After feature effects have been registered, a `UPDATE_EFFECTS` action will be dispatched.
This action will have all registered effects as its payload.

```ts
type UpdateEffects = {
type: typeof UPDATE_EFFECTS;
effects: string[];
};
```

For example, if you register your feature module as `EffectsModule.forFeature([SomeEffectsClass, AnotherEffectsClass])`,
it will have `SomeEffectsClass` and `AnotherEffectsClass` as its payload.

To dispatch an action when the `SomeEffectsClass` effect has been registered you can listen to the `UPDATE_EFFECTS` action and use the `effects` payload to filter out non-important effects.

```ts
@Effect()
init = this.actions.pipe(
ofType<UpdateEffects>(UPDATE_EFFECTS)
filter(action => action.effects.includes('SomeEffectsClass')),
map(action => ...)
);
```

## Actions

Stream of all actions dispatched in your application including actions dispatched by effect streams.
Expand Down

0 comments on commit 68f88c7

Please sign in to comment.