Interface Task<Args, Result>

Represents an async task.

interface Task<Args, Result> {
    cancel(): void;
    delay(delay, ...args): CancelablePromise<Result>;
    delayIfNotQueued(delay, ...args): CancelablePromise<Result>;
    isRunning(): boolean;
    run(...args): CancelablePromise<Result>;
}

Type Parameters

  • Args extends any[] = []
  • Result = void

Methods

  • Cancels the current execution.

    Returns void

  • Runs the task delayed. Cancels the last execution.

    Parameters

    • delay: number

      milliseconds to wait until task execution

    • Rest ...args: Args

      the arguments given to the task function.

    Returns CancelablePromise<Result>

    the promise.

  • Runs the task delayed. But only if it is not waiting for execution or executing. Does not cancel the last execution.

    Parameters

    • delay: number

      milliseconds to wait until next task execution.

    • Rest ...args: Args

      the arguments given to the task function. If queued again.

    Returns CancelablePromise<Result>

    the promise.

  • Returns the current running state.

    Returns boolean

Generated using TypeDoc