ngrx-workshop
  • Table of Contents
  • Setup and Configuration
  • Rules of Thumb
  • Rules of Thumb pt2
  • NgRx Libraries
    • NgRx Data
    • NgRx Entity
    • Action Creators
    • NgRx Auto Entity
  • NgRx Facades
    • NgRx Facades
  • Testing
    • Testing Factory
    • Testing Reducers
    • Testing Selectors
    • Testing Effects
  • Advanced Actions
    • 3 Types of Actions
    • Deciders
    • Splitter Actions
    • Aggregators
  • ToDo
    • Todo
Powered by GitBook
On this page

Was this helpful?

  1. Advanced Actions

Aggregators

  • Opposite of splitters

  • Combines multiple actions back down to one

  • Useful when flow needs to wait for actions to complete before next step

// Effect aggregators
@Effect()
aggregator = this.actions$.pipe(
 ofType<LoadUserById>(UserActionTypes.LoadUserById),
 flatMap(a =>
   zip(
     this.actions$.pipe(
       ofType<LoadUserByIdSuccess>(UserActionTypes.LoadUserByIdSuccess),
       first(t => t.payload.id === a.payload.id)
     ),
     this.actions$.pipe(
       ofType<Logged>(LogActionTypes.Logged),
       first(t => t.payload.id === a.payload.id)
     )
   )
 ),
 map(pair => new LoadAdminUserSuccess())
);
PreviousSplitter ActionsNextTodo

Last updated 5 years ago

Was this helpful?