为什么要使用两个过滤器?

问题描述 投票:2回答:1

为什么我们在下面的代码中使用两个过滤器而不是一个?

 fromEvent<MouseEvent>(this.mapElement, "click")
    .pipe(
        filter(e => !this.props.disableEvents),
        filter(_ => !this.mouseState.moved && mouseDownInMap)
    )
    .subscribe(e => {});

为什么不:

fromEvent<MouseEvent>(this.mapElement, "click")
    .pipe(filter( e => !this.props.disableEvents && !this.mouseState.moved && mouseDownInMap))
    .subscribe(e => {});

另外,如果.pipe()也可以在没有管道的情况下使用,为什么呢?

javascript rxjs rxjs6
1个回答
5
投票

可以

© www.soinside.com 2019 - 2024. All rights reserved.