angular - 为什么过滤rxjs后自定义管道有错误?
问题描述
我收到此错误:
Argument of type 'UnaryFunction<Observable<number>, Observable<any>>' is not assignable to parameter of type 'OperatorFunction<{ x: number; y: number; }, any>'
在线上:
this.Map.moveMap$
.pipe(
filter((v) => v.x !== 0 || v.y !== 0),
this.requestTextLayerPipe(),
)
.subscribe();
requestTextLayerPipe
自定义管道在哪里:
private requestTextLayerPipe() {
return pipe(
filter((currentScale: number) => currentScale <= this.scaleLimitTextLayer.max || currentScale >= this.scaleLimitTextLayer.min),
map(() => this.getTextLayersId()),
filter((dispar: string[]) => dispar.length > 0),
map((dispar: string[]) => this.getTextLayerProps(dispar)),
switchMap((props: RequestTextLayerProps) =>
this.Map.httpClient
.get(this.buildUrlRequestTextLayer(props), {
observe: 'body',
responseType: 'blob',
})
.pipe(
map((response) => {
return { props, response };
}),
catchError((error) => of(error)),
),
),
);
}
为什么我会收到此错误以及如何适应它?正如我所得到的,我应该将过滤器中的 observable 返回到requestTextLayerPipe
.
解决方案
因为在这里filter((currentScale: number)
你接受number
,但在第一个块中很明显这{ x: number; y: number; }
是预期的
推荐阅读
- asp.net - 在 ASP.NET Core Identity(独立)中,如何强制执行 2FA?
- automation - 如何使用 Katalon 自动化工具验证控制台日志 (INFO)
- swiftui - SwiftUI - 文本字段返回键事件
- html - 我希望用户只能从下拉列表中选择值,而不能在时间字段中输入
- google-apps-script - 如何在文件夹中的所有工作表上应用 Google 脚本
- xml - Pentaho 打开错误,而无法读取对象 xml 文件
- ios - NSManagedObject(context:) 构造函数和 NSEntityDescription.insertNewObject 之间的区别,用于将新对象插入 CoreData
- javascript - 反应胜利轴不显示
- vue.js - 在子 javascript 中向 vuejs 实例添加新方法
- python - python 队列中的内存是否会自动清除?