wesleyramalho / debounce

A personal implementation of debounce in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

debounce

A personal implementation of debounce in JavaScript

Usage example

In this example the alert happens only one time after 2000 milliseconds, regardless of the amount of user interactions until it stops. It can be used in events like onChange in ReactJS, for example.

import debounce from './debounce.js';

 const handleSearch = debounce(typing => {
    alert(typing);
  }, 2000);
  
 handleSearch('foo');

Reference: Throttle and Debounce patterns in JS

About

A personal implementation of debounce in JavaScript


Languages

Language:JavaScript 100.0%