I want to write this code with a relatively short code, can you advise some solution? Thanks!
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();
CodePudding user response:
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();