UNPKG

@figliolia/react-hooks

Version:

A small collection of simple React Hooks you're probably rewriting on a regular basis

15 lines (13 loc) 349 B
import type { Callback } from "Types"; import { DeferFN } from "./DeferFN"; export class Throttler<T extends Callback<any[], any>> extends DeferFN<T> { public execute = (...args: Parameters<T>) => { if (this.ID) { return; } this.callback(...args); this.ID = setTimeout(() => { this.cancel(); }, this.wait); }; }