1.0.2 • Published 6 years ago

debounce-example v1.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

Debounce example

Installation

npm i debounce-example@1.0.0

Usage

import debounce from 'debounce-example';

Parameters

debounce(fn, time)

Parameter nameValuerequired
fn - functionContains function to be executedyes
time - NumberIndicates time to executed the functionyes

About

The debounce function helps to manage time of execution your scripts. You can use this function to disabled multiple execution of some function. For example:

  • When you use a form to sent some data, and you need to prevent multiple call to the endpoint registration.

    import debounce from 'debounce-example';
    // Some function
    const myAwesomeRegistrationLogin = () => {
      fetch('http://my.api/user/registration', {
        method: 'POST',
        data: {name, email}
      }).then(() => someNotification('Success registration'));
    };

document.getElementById('registration--button').on('click', () => { debounce(myAwesomeRegistrationLogin, 5000); });