如何解决为什么自定义管道在过滤 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; }
是预期的
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。