Belin.io Core
    Preparing search index...

    Class Task<T>

    Represents an asynchronous operation.

    Type Parameters

    • T
    Index

    Constructors

    • Creates a new task.

      Type Parameters

      • T

      Parameters

      • task: (...args: any[]) => Promise<T>

        The code to execute in the task.

      Returns Task<T>

    Properties

    status: TaskStatus = TaskStatus.Created

    The task status.

    Accessors

    • get error(): null | Error

      The error that caused this task to end prematurely, or null if the task completed successfully or has not yet thrown any errors.

      Returns null | Error

    • set error(error: unknown): void

      Parameters

      • error: unknown

      Returns void

    • get isCompleted(): boolean

      Value indicating whether this task has completed.

      Returns boolean

    • get isCompletedSuccessfully(): boolean

      Value indicating whether this task ran to completion.

      Returns boolean

    • get isFaulted(): boolean

      Value indicating whether this task completed due to an unhandled error.

      Returns boolean

    • get result(): undefined | T

      The result value of this task, if it has completed successfully.

      Returns undefined | T

    • set result(value: undefined | T): void

      Parameters

      • value: undefined | T

      Returns void

    Methods

    • Runs the task.

      Parameters

      • ...args: any[]

        The task arguments.

      Returns Promise<undefined | T>

      The task esult, if it has completed successfully.