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

Splitter Actions

  • Splits a single action in to an array of actions

  • Simplifies flows where multiple actions need to dispatch

// Effect splitter
@Effect()
splitter = this.actions$.pipe(
 ofType<LoadAdminUser>(UserActionTypes.LoadAdminUser),
 flatMap(add => [
   new LoadUserById({ id: add.payload.id }),
   new LogOperation({ loggedAction: add.type, payload: add.payload })
 ])
);

Must use flatMap or NgRx will throw an error

PreviousDecidersNextAggregators

Last updated 5 years ago

Was this helpful?