Catalysing your Angular 4 app Performance
Param Singh
111

Thanks for the article. For scrolling I came with next some time ago:

this.zone.runOutsideAngular(() => {
this.subscriptions.push(
Observable.fromEvent(this.scrollSource, 'scroll')
// .throttleTime(300)
// .merge(obs.debounceTime(300)) // need to merge debounced event or we loose some events on fast scroll
.sampleTime(300) // gives best result and no need to merge several streams
.subscribe((e: UIEvent) => {
this.zone.run(() => {
this.onScroll(e);
});
}
)
);
});

sampleTime working better for me (similar directive). Maybe not an issue for 20ms delay, but I wanted to use longer delay to reduce possible overhead (and count of events emitted by directive) to minimum.

Show your support

Clapping shows how much you appreciated Vladimir Tolstikov’s story.