Search code examples
angulartypescriptngrxngrx-effects

In which order are executed effects in NGRX


Let's say I have one action A and two effects subscribing to it :

@Injectable
export class CustomEffects {
  constructor(
    private actions$: Actions,
  ) { }

  effect_1$ = createEffect(() => this.actions$.pipe(
    ofType(Actions.A),
    map(() => Actions.B)
  ));

  effect_2$ = createEffect(() => this.actions$.pipe(
    ofType(Actions.A),
    map(() => Actions.C)
  ));
}

Does there is a specific order in which the actions will be thrown ? Like B then C following subscription order ?


Solution

  • It does this from top to bottom (top is registered first). You can double-check this by adding a log inside each effect.