Class Task

Represents and manages a state of an asynchronous task.

The task itself can accept one arbitrarily-typed argument.

Type parameters

Type parameter Description
TArg

the task's argument type

TResult

the task's result type

TProgress

the task's progress readout type

constructor

  • Instantiates the task state with an action.

    Parameters

    • action: TaskAction<TArg, TResult, TProgress>

      the task's action.

    • Optional options: TaskOptions<TProgress>

    Returns Task

action

action: TaskAction<TArg, TResult, TProgress>

the task's action.

devOptions

devOptions: StateDevOptions

Development-time settings

isPending

  • get isPending(): boolean
  • Returns true if the task is in pending state.

    Returns boolean

name

  • get name(): null | string
  • Returns the UI state's debug name.

    Returns null | string

progress

  • get progress(): undefined | TProgress
  • Returns the last reported progress of the pending task. Has no meaning if the task is not in pending state.

    Returns undefined | TProgress

promise

  • get promise(): null | Promise<void>
  • Returns the promise that resolves when the task is completed or is canceled.

    Returns null | Promise<void>

result

  • get result(): void | TResult
  • Returns the result of the last completed task.

    Returns void | TResult

cancel

  • cancel(): void
  • Cancels the pending task. If there isn't one, this call is no-op.

    Returns void

invoke

  • invoke(args: TArg): Promise<void>
  • Runs the task.

    Parameters

    • args: TArg

      The arbitrary argument to pass to the task.

    Returns Promise<void>

Generated using TypeDoc