Class Poll<T, U, V>

A class that wraps an asynchronous function to poll at a regular interval with exponential increases to the interval length if the poll fails.

Typeparam

T - The resolved type of the factory's promises. Defaults to any.

Typeparam

U - The rejected type of the factory's promises. Defaults to any.

Typeparam

V - An optional type to extend the phases supported by a poll. Defaults to standby, which already exists in the Phase type.

Type Parameters

  • T = any
  • U = any
  • V extends string = "standby"

Implements

Constructors

Properties

_disposed: Signal<Poll<T, U, V>, void> = ...
_factory: Factory<T, U, V>
_frequency: Frequency
_linger: number
_lingered: number = 0
_standby: Standby | (() => boolean | Standby)

Type declaration

    • (): boolean | Standby
    • Returns boolean | Standby

_state: State<T, U, V>
_tick: PromiseDelegate<Poll<T, U, V>> = ...
_ticked: Signal<Poll<T, U, V>, State<T, U, V>> = ...
_timeout: undefined | number
name: string

The name of the poll.

Accessors

Methods

  • Refreshes the poll. Schedules refreshed tick if necessary.

    Returns Promise<void>

    A promise that resolves after tick is scheduled and never rejects.

    Notes

    The returned promise resolves after the tick is scheduled, but before the polling action is run. To wait until after the poll action executes, await the poll.tick promise: await poll.refresh(); await poll.tick;

  • Schedule the next poll tick.

    Parameters

    • next: Partial<State<T, U, V> & {
          cancel: ((last) => boolean);
      }> = {}

      The next poll state data to schedule. Defaults to standby.

    Returns Promise<void>

    A promise that resolves when the next poll state is active.

    Notes

    This method is not meant to be invoked by user code typically. It is public to allow poll instances to be composed into classes that schedule ticks.