TaskExecution

Represents the execution of a Task, with methods to cancel it, react to its results, and retrieve its eventual value. TaskExecution objects aren't created directly by users, but instead returned as a result from Task's run() method. b

This feature is experimental!

This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.

Documentation

Represents the execution of a Task, with methods to cancel it, react to its results, and retrieve its eventual value. TaskExecution objects aren't created directly by users, but instead returned as a result from Task's run() method. b

Static properties

Special values

prototype

The container for instance methods for the TaskExecution structure.

Experimental

Instance (prototype) properties

Cancelling tasks

cancel()

Cancels a task execution. Does nothing if the task has already been resolved.

Extracting eventual values

future()

Gets the eventual value of a Task as a Folktale Future.

promise()

Gets the eventual value of the task as a JavaScript's Promise.

Reacting to Task state transitions

listen()

Adds a functions to be called when the task settles for each possible state it can transition to.

Types

constructor()

Represents the execution of a Task, with methods to cancel it, react to its results, and retrieve its eventual value. TaskExecution objects aren't created directly by users, but instead returned as a result from Task's run() method. b

Experimental

(Uncategorised)

Source Code

Defined in source/concurrency/task/_task-execution.js at line 11, column 0
class TaskExecution {
  /*~*/
  constructor(task, deferred) {
    this._task = task;
    this._deferred = deferred;
    this._links = [];
  }

  /*~*/
  cancel() {
    this._deferred.maybeCancel();
    this._links.forEach(link => link.cancel());
    return this;
  }

  /*~*/
  listen(pattern) {
    this._deferred.listen(pattern);
    return this;
  }

  /*~*/
  promise() {
    return this._deferred.promise();
  }

  /*~*/
  future() {
    return this._deferred.future();
  }

  /*~*/
  link(execution) {
    this._links.push(execution);
    return this;
  }
}
Stability
experimental
Licence
MIT
Module
folktale/concurrency/task/_task-execution
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)