Understanding the debounce function and how it can be used to control API requests

Have you noticed when using any generic search bar across the web there is often a small delay before your search results appear. This functionality is often controlled by a debounce function, which prevents the search API request from being made until the user stops typing for a pre-determined set of time. Without it, a large number of redundant requests will be made, with one being made per keystroke event by the user.

Let's see it in action

Jack Perrin

Software Developer, Sport & Beer lover

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store