module folktale/concurrency/future

A data structure to represent the result of an asynchronous computation.

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

A data structure to represent the result of an asynchronous computation.

Results are not constructed directly (generally), but rather returned when asking for the eventual value of a task execution.

Example:

const { task } = require('folktale/concurrency/task');

const one = task(resolver => resolver.resolve(1));

one.run().future().map(value => {
  $ASSERT(value == 1);
});

Properties

Constructing

of(value)

Constructs a Future holding a successful value.

Experimental
rejected(reason)

Constructs a future holding a failure value.

Experimental

Converting from other types

fromPromise(aPromise)

Converts a Promise to a folktale Future.

Experimental

Types

_Deferred: Deferred()

A deferred is an internal structure for creating Futures. Because deferred is an imperative structure, users should instead construct futures through the Task structure.

Experimental
_ExecutionState

An union defining the possible states of a Future.

Experimental
_Future()

Models the eventual result of asynchronous computations.

Experimental

Source Code

Defined in source/concurrency/future/index.js at line 16, column 0
{
  of: Future.of,
  rejected: Future.rejected,
  fromPromise: Future.fromPromise,
  _Deferred: require('./_deferred'),
  _ExecutionState: require('./_execution-state'),
  _Future: Future
}
Stability
experimental
Licence
MIT
Module
folktale/concurrency/future
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)