So we have this ordinary effect doSomething. What is the official way to dispatch another action, named doSomethingElse? The documentation doesn't really say anything about the right way. In the end there might not be much difference, yet I don't really like the fact I could use dispatch: false in like 95% of my codebase.
Dispatching action by using dispatch: false:
doSomething$ = createEffect(() =>
this.actions$.pipe(
ofType(AuthActions.doSomething),
map(() => AuthActions.doSomethingElse())
));
doSomethingElse$ = createEffect(
() =>
this.actions$.pipe(
ofType(AuthActions.doSomethingElse),
tap(() => console.log('it works!'))
),
{ dispatch: false });
Dispatching action without dispatch: false:
doSomething$ = createEffect(
() =>
this.actions$.pipe(
ofType(AuthActions.doSomething),
tap(() => {
this.store.dispatch(AuthActions.doSomethingElse());
})
),
{ dispatch: false });
doSomethingElse$ = createEffect(
() =>
this.actions$.pipe(
ofType(AuthActions.doSomethingElse),
tap(() => console.log('it works!'))
),
{ dispatch: false });
Both solutions work, yet I am not sure which is the correct way of using NgRx.