我们如何在 angular 中用 createEffect 替换 Effect 代码以进行日志记录……?

How we can replace Effect code with createEffect in angular for logging..?

任何人都可以帮我解决如何使用 createEffect 转换下面的 Effect 代码吗?正如我们所知,该效果已被弃用。?

  @Effect()
LogIn: Observable<any> = this.actions.pipe(
  ofType(AuthActionTypes.LOGIN)
  .map((action: LogIn) => action.payload)
  .switchMap((payload: any) => {
    return this.authService.logIn(payload.email, payload.password).
      .map((user: any) => {
        console.log(user);
        return new LogInSuccess({token: user.token, email: payload.email});
      })
      .catch((error: any) => {
        console.log(error);
        // return Observable.of(new LogInFailure({ error: error }));
      });
  }));

提前致谢!! 注意* :- 我正在为此使用以下文档 https://mherman.org/blog/authentication-in-angular-with-ngrx/


LogIn: Observable<any> = createEffect(() => {
  return this.actions.pipe(
  ofType(AuthActionTypes.LOGIN),
  map((action: LogIn) => action.payload),
  switchMap((payload: any) => {
    return this.authService.logIn(payload.email, payload.password).pipe(
      map((user: any) => {
        console.log(user);
        return new LogInSuccess({token: user.token, email: payload.email});
      }),
      catchError((error: any) => {
        console.log(error);
        return of(new LogInFailure({ error: error }));
      });
  })
});