Search code examples
angularrxjsrxjs6

Why custom pipe has error after filter rxjs?


I get this error:

Argument of type 'UnaryFunction<Observable<number>, Observable<any>>' is not assignable to parameter of type 'OperatorFunction<{ x: number; y: number; }, any>'

on the line:

  this.Map.moveMap$
            .pipe(
                filter((v) => v.x !== 0 || v.y !== 0),
                this.requestTextLayerPipe(),
            )
            .subscribe();

Where requestTextLayerPipe is custom pipe:

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)),
                ),
        ),
    );
}

Why do I get this error and how to fit it? As I got, I should return observable in filter to requestTextLayerPipe.


Solution

  • because here filter((currentScale: number) you accept number, but in first block it is obvious that { x: number; y: number; } is expected