Options
All
  • Public
  • Public/Protected
  • All
Menu

A queue.

Type parameters

  • T = never

    The type of method names to be replaced by queued versions.

Hierarchy

  • Queue

Index

Constructors

constructor

  • new Queue<T>(options?: QueueOptions): Queue<T>
  • Construct a new Queue.

    Type parameters

    • T = never

    Parameters

    • Optional options: QueueOptions

      Queue configuration.

    Returns Queue<T>

Properties

Private _extended

_extended: any

Private _flushIfNeeded

_flushIfNeeded: any

Check whether the queue needs to be flushed.

Private Readonly _queue

_queue: any

Private _timeout

_timeout: any

delay

delay: null | number

Delay in milliseconds. If defined the queue will be periodically flushed.

max

max: number

Maximum number of entries in the queue before it will be flushed.

Methods

destroy

  • destroy(): void
  • Destroy the queue. The queue will first flush all queued actions, and in case it has extended an object, will restore the original object.

    Returns void

flush

  • flush(): void
  • Flush all queued calls

    Returns void

queue

  • queue(entry: QueueCallEntry): void
  • Queue a call.

    Parameters

    • entry: QueueCallEntry

      The function or entry to be queued.

    Returns void

replace

  • replace<M>(object: Record<M, () => void>, method: M): void
  • Replace a method on an object with a queued version.

    Type parameters

    • M: string

    Parameters

    • object: Record<M, () => void>

      Object having the method.

    • method: M

      The method name.

    Returns void

setOptions

  • setOptions(options?: QueueOptions): void
  • Update the configuration of the queue.

    Parameters

    • Optional options: QueueOptions

      Queue configuration.

    Returns void

Static extend

  • extend<O, K>(object: O, options: QueueExtendOptions<K>): Queue<O>
  • Extend an object with queuing functionality. The object will be extended with a function flush, and the methods provided in options.replace will be replaced with queued ones.

    Type parameters

    • O: { flush?: any }

    • K: string

    Parameters

    • object: O

      The object to be extended.

    • options: QueueExtendOptions<K>

      Additional options.

    Returns Queue<O>

    The created queue.

Generated using TypeDoc