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

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;
  }

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

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

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

  /*~*/
  future() {
    return this._deferred.future();
  }
}
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/)