问题描述
我收到此错误:
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; }
是预期的