DebounceTime

Angular - Creating a Debounce Directive(s)

Published on

A very common and useful directive that we can create is a simple debounce directive. If you’re not familiar with debouncing, it essentially will discard events or values until a specified time has ellapsed between the emission of those events/values. This is commonly used to prevent spam button clicks or spamming an API call from a autocomplete/search input. We’re going to create two debounce directives, one to debounce key up events that will be used on input elements and another to debounce button clicks.