Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • R

Hierarchy

  • Promise

Implements

Index

Constructors

Methods

Constructors

constructor

  • new Promise(callback: function): Promise
  • If you call resolve in the body of the callback passed to the constructor, your promise is fulfilled with result object passed to resolve. If you call reject your promise is rejected with the object passed to resolve. For consistency and debugging (eg stack traces), obj should be an instanceof Error. Any errors thrown in the constructor callback will be implicitly passed to reject().

    Parameters

    • callback: function
        • (resolve: function, reject: function): void
        • Parameters

          • resolve: function
              • Parameters

                Returns void

          • reject: function
              • (error?: any): void
              • Parameters

                • Optional error: any

                Returns void

          Returns void

    Returns Promise

Methods

catch

  • catch<U>(onRejected?: function): Promise<U>
  • Sugar for promise.then(undefined, onRejected)

    Type parameters

    • U

    Parameters

    • Optional onRejected: function

      called when/if "promise" rejects

    Returns Promise<U>

then

  • then<U>(onFulfilled?: function, onRejected?: function): Promise<U>
  • then<U>(onFulfilled?: function, onRejected?: function): Promise<U>
  • onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. Both callbacks have a single parameter , the fulfillment value or rejection reason. "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. If an error is thrown in the callback, the returned promise rejects with that error.

    Type parameters

    • U

    Parameters

    • Optional onFulfilled: function

      called when/if "promise" resolves

    • Optional onRejected: function

      called when/if "promise" rejects

    Returns Promise<U>

  • Type parameters

    • U

    Parameters

    • Optional onFulfilled: function
    • Optional onRejected: function
        • (error: any): void
        • Parameters

          • error: any

          Returns void

    Returns Promise<U>

Static all

  • Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. the array passed to all can be a mixture of promise-like objects and other objects. The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.

    Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    • T10

    Parameters

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    • T9

    Parameters

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    • T8

    Parameters

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    • T7

    Parameters

    Returns Promise<[T1, T2, T3, T4, T5, T6, T7]>

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    • T6

    Parameters

    Returns Promise<[T1, T2, T3, T4, T5, T6]>

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    • T5

    Parameters

    Returns Promise<[T1, T2, T3, T4, T5]>

  • Type parameters

    • T1

    • T2

    • T3

    • T4

    Parameters

    Returns Promise<[T1, T2, T3, T4]>

  • Type parameters

    • T1

    • T2

    • T3

    Parameters

    Returns Promise<[T1, T2, T3]>

  • Type parameters

    • T1

    • T2

    Parameters

    Returns Promise<[T1, T2]>

  • Type parameters

    • T1

    Parameters

    Returns Promise<[T1]>

  • Type parameters

    • TAll

    Parameters

    Returns Promise<TAll[]>

Static race

  • Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.

    Type parameters

    • R

    Parameters

    Returns Promise<R>

Static reject

  • reject<R>(error: any): Promise<R>
  • Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error

    Type parameters

    • R

    Parameters

    • error: any

    Returns Promise<R>

Static resolve

  • Make a new promise from the thenable. A thenable is promise-like in as far as it has a "then" method.

    Returns Promise<void>

  • Type parameters

    • R

    Parameters

    Returns Promise<R>

Generated using TypeDoc