Options
All
  • Public
  • Public/Protected
  • All
Menu

A task is a computation that should produce a definite goal after a finite time. This class is used to allow the task to happen in a way that does not completely block the JavaScript virtual machine. The task will happen in cycles that run for a maximum amount of time before relinquishing control.

Hierarchy

  • TaskRunner

Index

Constructors

constructor

Properties

Private _boundWrapper

_boundWrapper: Function = this._workWrapper.bind(this)

Private _maxTimespan

_maxTimespan: number = 100

Private _state

_state: BehaviorSubject<State>

Private _timeout

_timeout: number = 0

Private _timeoutId

_timeoutId: number | undefined

state

state: Observable<State>

Private task

task: Task

The computation controlled by this runner.

Accessors

completed

  • get completed(): boolean

running

  • get running(): boolean

terminated

  • get terminated(): boolean

Methods

Private _setTimeoutId

  • _setTimeoutId(value: number | undefined): void

Private _stateFieldChange

  • _stateFieldChange<T>(field: T, value: State[T]): void
  • Type parameters

    • T: keyof State

    Parameters

    • field: T
    • value: State[T]

    Returns void

Private _work

  • _work(): boolean
  • Keeps the task running by launching cycles only until done or until the maximum time span for one run is reached.

    Returns boolean

    False if there is no more work to do. True otherwise.

Private _workWrapper

  • _workWrapper(): void
  • Convenience method. The bound version of this method (this._boundWrapper) is what is called by the timeouts.

    Returns void

onCompleted

  • onCompleted(): Promise<State>

reset

  • reset(): void
  • Resets the task to its initial state. The task will be deemed incomplete.

    Returns void

resume

  • resume(): void
  • Resumes the task. This method does not change the completion status of the task. So it is possible to stop a task temporarily and resume it later from where it stopped.

    Returns void

start

  • start(): void

stop

  • stop(): void

terminate

  • terminate(): void

Generated using TypeDoc