【发布时间】:2021-06-26 07:17:06
【问题描述】:
我收到此错误:
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。
【问题讨论】: