如何在 Rx Js observables 中通过简单的解决方案更改多过滤器运算符?
How to change multi filter operators with a brief solution, in Rx Js observables?
我想用一个比较短的代码来写这段代码,你能建议一些解决方案吗?
谢谢!
fromEvent(document, 'click').pipe(
filter(e => e.target !== this.one.nativeElement),
filter(e => e.target !== this.two.nativeElement),
filter(e => e.target !== this.three.nativeElement),
map(() => console.log('target'))
.subscribe();
fromEvent(document, 'click').pipe(
filter(e => ![
this.one.nativeElement,
this.two.nativeElement,
this.three.nativeElement
].some(elem => e.target === elem)),
map(() => console.log('target'))
).subscribe();
我想用一个比较短的代码来写这段代码,你能建议一些解决方案吗? 谢谢!
fromEvent(document, 'click').pipe(
filter(e => e.target !== this.one.nativeElement),
filter(e => e.target !== this.two.nativeElement),
filter(e => e.target !== this.three.nativeElement),
map(() => console.log('target'))
.subscribe();
fromEvent(document, 'click').pipe(
filter(e => ![
this.one.nativeElement,
this.two.nativeElement,
this.three.nativeElement
].some(elem => e.target === elem)),
map(() => console.log('target'))
).subscribe();