debounceTime() operator

The sampleTime() operator was able to ignore the user for a certain period of time, but the debounceTime() operator takes a different approach. Debounce as a concept means that we wait for things to calm down before emitting a value. Imagine an input element that the user types into. The user will stop typing eventually. We want to make sure the user has actually stopped, so we wait for a while before we actually do something. This is what the debounceTime() operator does for us. The following example shows how we can listen to the user typing into an input element, wait for the user to stop typing, and lastly, perform an AJAX call:

// time/debounceTime.jsconst elem = document.getElementById("input");let stream$ 

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.