I have an ngrx effect that involves calling an HTTP method and then waiting for 2 seconds before redirecting to another page.
However, the current behavior is that it redirects immediately without waiting.
confirmRegistration$ = createEffect(() => {
return this.actions$.pipe(
ofType(AuthActions.confirmRegistrationAction),
exhaustMap((action) => {
return this.authHttpService.confirmRegistration(action.payload).pipe(
map((res: ConfirmRegistrationResponse) => {
this.authService.setLocalStorageAuthToken(res.token);
return AuthActions.confirmRegistrationSuccess(res);
}),
tap(interval(2000).pipe(take(1)).subscribe(_ =>
this.router.navigate(['/dashboard'])
)),
catchError((error) => of(AuthActions.confirmRegistrationFailure({ error })))
);
})
);
});