Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Debouncer<T, U, V>

Wraps and debounces a function that can be called multiple times and only executes the underlying function one interval after the last invocation.

Type parameters

  • T

    The resolved type of the underlying function. Defaults to any.

  • U

    The rejected type of the underlying function. Defaults to any.

  • V: any[]

    Arguments for the underlying function. Defaults to any[].

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Debouncer(fn: function, limit?: number): Debouncer
  • Instantiate a rate limiter.

    Parameters

    • fn: function

      The function to rate limit.

        • (...args: V): T | Promise<T>
        • Parameters

          • Rest ...args: V

          Returns T | Promise<T>

    • Default value limit: number = 500

      The rate limit; defaults to 500ms.

    Returns Debouncer

Properties

Protected args

args: V | undefined = undefined

Arguments for the underlying function.

limit

limit: number

The rate limit in milliseconds.

Protected payload

payload: PromiseDelegate<T> | null = null

A promise that resolves on each successful invocation.

Protected poll

poll: Poll<T, U, "invoked">

The underlying poll instance used by the rate limiter.

Accessors

isDisposed

  • get isDisposed(): boolean

Methods

dispose

  • dispose(): void

invoke

  • invoke(...args: V): Promise<T>

stop

  • stop(): Promise<void>

Generated using TypeDoc