Skip to main content

Web3DeferredPromise <T>

The class is a simple implementation of a deferred promise with optional timeout functionality, which can be useful when dealing with asynchronous tasks.

Implements

Index

Constructors

publicconstructor

  • new Web3DeferredPromise<T>(__namedParameters?: { eagerStart: boolean; timeout: number; timeoutMessage: string }): Web3DeferredPromise<T>
  • Type parameters

    • T

    Parameters

    • __namedParameters: { eagerStart: boolean; timeout: number; timeoutMessage: string } = ...
      • eagerStart: boolean
      • timeout: number
      • timeoutMessage: string

    Returns Web3DeferredPromise<T>

Properties

public[toStringTag]

[toStringTag]: Promise = 'Promise'

Accessors

publicstate

  • get state(): pending | fulfilled | rejected
  • Returns the current state of the promise.


    Returns pending | fulfilled | rejected

    'pending' | 'fulfilled' | 'rejected'

Methods

publiccatch

  • catch<TResult>(onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>

  • Type parameters

    • TResult

    Parameters

    • optionalonrejected: (reason: any) => TResult | PromiseLike<TResult>

      (optional) The callback to execute when the promise is rejected.

      Returns Promise<T | TResult>

    publicfinally

    • finally(onfinally?: () => void): Promise<T>

    • Parameters

      • optionalonfinally: () => void

        (optional) The callback to execute when the promise is settled (fulfilled or rejected).

        Returns Promise<T>

      publicreject

      • reject(reason?: unknown): void
      • Rejects the current promise.


        Parameters

        • optionalreason: unknown

          The reason to reject the promise with.

        Returns void

      publicresolve

      • resolve(value: T | PromiseLike<T>): void
      • Resolves the current promise.


        Parameters

        • value: T | PromiseLike<T>

          The value to resolve the promise with.

        Returns void

      publicstartTimer

      • startTimer(): void
      • Starts the timeout timer for the promise.


        Returns void

      publicthen

      • then<TResult1, TResult2>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: unknown) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>

      • Type parameters

        • TResult1
        • TResult2

        Parameters

        • optionalonfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>

          (optional) The callback to execute when the promise is fulfilled.

          • optionalonrejected: (reason: unknown) => TResult2 | PromiseLike<TResult2>

            (optional) The callback to execute when the promise is rejected.

            Returns Promise<TResult1 | TResult2>