Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "function/debounce"

Index

Type aliases

TDebounceFunction

TDebounceFunction<T>: function

Type parameters

  • T

Type declaration

    • (...args: any[]): T | Promise<T>
    • Parameters

      • Rest ...args: any[]

      Returns T | Promise<T>

Variables

Const DEFAULT_DEBOUNCE_TIME

DEFAULT_DEBOUNCE_TIME: 180 = 180

Functions

debounce

  • debounce<T>(callback: TDebounceFunction<T>, time?: number, thisObject?: any, ...args: any[]): Promise<T>

  • Example usage:

    import { debounce } from "@thalesrc/js-utils/promise";
    
    function foo() {
      console.log("hello");
    }
    
    for (let i = 0; i < 5; i++) {
      debounce(foo);
    }
    
    // logs "hello" only once

    Static usage example:

    import "@thalesrc/js-utils/dist/as-proto/debounce";
    
    function foo() {
      console.log("hello");
    }
    
    for (let i = 0; i < 5; i++) {
      foo.debounce();
    }
    
    // logs "hello" only once

    Type parameters

    • T

    Parameters

    • callback: TDebounceFunction<T>

      The function to execute only last of multiple execute requests by given time

    • Default value time: number = DEFAULT_DEBOUNCE_TIME
    • Default value thisObject: any = null
    • Rest ...args: any[]

      Function arguments

    Returns Promise<T>

    A promise which resolves right after the debouncing sequence has been finished

debounceWithKey

  • debounceWithKey<T>(key: symbol, callback: TDebounceFunction<T>, time?: number, thisObject?: any, ...args: any[]): Promise<T>
  • Type parameters

    • T

    Parameters

    • key: symbol
    • callback: TDebounceFunction<T>
    • Default value time: number = DEFAULT_DEBOUNCE_TIME
    • Default value thisObject: any = null
    • Rest ...args: any[]

    Returns Promise<T>

Generated using TypeDoc