@terminus/ngx-tools
Version:
[![CircleCI][circle-badge]][circle-link] [![codecov][codecov-badge]][codecov-project] [![semantic-release][semantic-release-badge]][semantic-release] [![MIT License][license-image]][license-url] <br> [![NPM version][npm-version-image]][npm-url] [![Github
20 lines (19 loc) • 823 B
TypeScript
/**
* Return a function, that, as long as it continues to be invoked, will not be triggered. The
* function will be called after it stops being called for N milliseconds.
*
* @param func - The function to call after the debounce period
* @param wait - The length of time to wait between calls (ms)
* @param immediate - Whether the debounced function should be fired immediately
* @param windowRef - A reference to the global window object
* @returns The debounced function
*
* @example
* const myFunc = () => {console.log('hi!')};
* const myDebouncedFunc = debounce(myFunc, 200);
* myDebouncedFunc();
* myDebouncedFunc();
* myDebouncedFunc();
* // 'hi!' will only be logged once
*/
export declare function debounce<Context>(func: Function, wait: number, immediate?: boolean, windowRef?: Window): Function;