ngrx-workshop
Search…
Splitter Actions
  • Splits a single action in to an array of actions
  • Simplifies flows where multiple actions need to dispatch
1
// Effect splitter
2
@Effect()
3
splitter = this.actions$.pipe(
4
ofType<LoadAdminUser>(UserActionTypes.LoadAdminUser),
5
flatMap(add => [
6
new LoadUserById({ id: add.payload.id }),
7
new LogOperation({ loggedAction: add.type, payload: add.payload })
8
])
9
);
Copied!
Must use flatMap or NgRx will throw an error
Last modified 2yr ago
Copy link