ngrx-workshop
Search…
Aggregators
  • Opposite of splitters
  • Combines multiple actions back down to one
  • Useful when flow needs to wait for actions to complete before next step
1
// Effect aggregators
2
@Effect()
3
aggregator = this.actions$.pipe(
4
ofType<LoadUserById>(UserActionTypes.LoadUserById),
5
flatMap(a =>
6
zip(
7
this.actions$.pipe(
8
ofType<LoadUserByIdSuccess>(UserActionTypes.LoadUserByIdSuccess),
9
first(t => t.payload.id === a.payload.id)
10
),
11
this.actions$.pipe(
12
ofType<Logged>(LogActionTypes.Logged),
13
first(t => t.payload.id === a.payload.id)
14
)
15
)
16
),
17
map(pair => new LoadAdminUserSuccess())
18
);
Copied!
Copy link