Skip to main content

OpenPromise <T>

Implements

  • Promise<T>

Index

Constructors

constructor

  • new OpenPromise<T>(executor?: PromiseExecutor<T>, lazy?: boolean): OpenPromise<T>
  • Type parameters

    • T

    Parameters

    • executor: PromiseExecutor<T> = null
    • lazy: boolean = false

    Returns OpenPromise<T>

Properties

readonly[toStringTag]

[toStringTag]: string = 'OpenPromise'

readonlycatch

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

Type declaration

    • <TResult>(onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>
    • Attaches a callback for only the rejection of the Promise.


      Type parameters

      • TResult = never

      Parameters

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

        The callback to execute when the Promise is rejected.

      Returns Promise<T | TResult>

      A Promise for the completion of the callback.

readonlyexecutor

executor: PromiseExecutor<T> = null

readonlyfinally

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

Type declaration

    • (onfinally?: () => void): Promise<T>
    • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.


      Parameters

      • optionalonfinally: () => void

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

      Returns Promise<T>

      A Promise for the completion of the callback.

readonlylazy

lazy: boolean = false

readonlypromise

promise: Promise<T>

rejectedReason

rejectedReason: Error = null

resolvedValue

resolvedValue: T = null

state

state: OpenPromiseState = OpenPromiseState.Idle

readonlythen

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

Type declaration

    • <TResult1, TResult2>(onfulfilled?: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>
    • Attaches callbacks for the resolution and/or rejection of the Promise.


      Type parameters

      • TResult1 = T
      • TResult2 = never

      Parameters

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

        The callback to execute when the Promise is resolved.

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

        The callback to execute when the Promise is rejected.

      Returns Promise<TResult1 | TResult2>

      A Promise for the completion of which ever callback is executed.

Methods

execute

  • execute(): void
  • Returns void

reject

  • reject(reason: Error): void
  • Parameters

    • reason: Error

    Returns void

resolve

  • resolve(value: T | PromiseLike<T>): void
  • Parameters

    • value: T | PromiseLike<T>

    Returns void