Skip to main content

Task <Payload, Result>

Hierarchy

  • Deferred<Result>
    • Task

Index

Constructors

publicconstructor

  • new Task<Payload, Result>(payload: Payload): Task<Payload, Result>
  • Type parameters

    • Payload
    • Result

    Parameters

    • payload: Payload

    Returns Task<Payload, Result>

Accessors

[toStringTag]

  • get [toStringTag](): string
  • Returns a string representation of the object.


    Returns string

publicpayload

  • get payload(): Payload
  • Returns Payload

publicsignal

  • get signal(): AbortSignal
  • Returns AbortSignal

state

  • get state(): DeferredState
  • Gets the current state of the deferred promise.

    @see

    Returns DeferredState

Methods

catch

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


    Type parameters

    • TResult = never

    Parameters

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

      Returns Promise<Result | TResult>

    finally

    • finally(onfinally?: null | () => void): Promise<Result>
    • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The


      Parameters

      • optionalonfinally: null | () => void

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

        Returns Promise<Result>

      reject

      • reject(reason?: any): void
      • Rejects the promise with a reason.


        Parameters

        • optionalreason: any

          The reason why the promise was rejected.

        Returns void

      resolve

      • resolve(value: Result | PromiseLike<Result>): void
      • Resolves the promise with a value or the result of another promise.


        Parameters

        • value: Result | PromiseLike<Result>

          The value to resolve the promise with.

        Returns void

      publicshare

      • share(signal?: AbortSignal): Promise<Result>
      • Parameters

        • optionalsignal: AbortSignal

        Returns Promise<Result>

      then

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


        Type parameters

        • TResult1 = Result
        • TResult2 = never

        Parameters

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

          The callback to execute when the promise is resolved.

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

            The callback to execute when the promise is rejected.

            Returns Promise<TResult1 | TResult2>