how in rxjs bubble a scroll event

Viewed 747

with vanilla js, I can write something like this to catch any scroll on any element (pay attention to true as the last argument)

document.addEventListener('scroll', function(e) {
   console.log(e);
}, true);

but with rxjs I can't do the bubbling (or I don't know how) and something like this doesn't work

fromEvent(window, 'scroll').subscribe(console.log);

how to register an event in rxjs that support bubbling?

1 Answers

You can pass options to fromEvent (see Examples) as well:

fromEvent(window, 'scroll', { capture: true }).subscribe(console.log);

// or

fromEvent(window, 'scroll', true).subscribe(console.log);
Related