angular - 为什么我在使用 ngrx 效果时会收到这个可观察到的警告
问题描述
我有一个使用ngrx 效果的角度应用程序,我正在使用它加载firestore 数据。我目前收到此警告:
您在预期流的位置提供了 '() => ({ type })'。您可以提供 Observable、Promise、Array 或 Iterable。
这是我的ngrx效果
loadVendors$: Observable<Action> = createEffect(() => this.actions$.pipe(
ofType(fromVendorActions.loadVendors),
switchMap(() => this.store.select(fromRoot.getRouterState)),
tap((ev: any)=> console.log('before', ev)),
switchMap((action:any) => this.vendorService.getVendors(action.state.params.vendorGroupId)),
tap((ev: any)=> console.log('after', ev)),
map((vendors: any) => fromVendorActions.loadVendorsSuccess({vendors: vendors})),
catchError(() => fromVendorActions.loadVendorsFail)
))
我正在从操作切换,获取我所在页面的参数,然后从我的服务切换到可观察对象以检索一些数据作为可观察对象。
使用 tap() 检查流我似乎得到了我所期望的。警告出现在我正在记录流的 (2) 个水龙头之间的控制台中。数据正在正确加载到商店中,但警告让我很烦。
解决方案
catchError
应该返回一个可观察的:
catchError(() => of(fromVendorActions.loadVendorsFail))
推荐阅读
- powershell - 如何从 PowerShell 脚本调整 Windows 10 上的 Docker 桌面虚拟机的大小?
- r - R中的频率计数
- git - 如何在 gitkraken 中显示 git reflog 条目
- javascript - 为 Angular 聊天创建可滚动的 div
- mysql - 如何使用sql在同一表中的列的特定日期之后获取所有值
- asp.net-core - NET Core 3.1 - HTTP 错误 500.30 - ANCM 进程内启动失败
- django - Django + Apache(httpd):加载 MySQLdb 模块时出错
- r - 我每次都想要 5 毫米的箱子,在一个分析不同正态分布的 R 脚本中
- c++ - C++ 项目没有找到它的头文件 (visual studio)
- android - 当应用程序处于后台时显示抬头通知