fromPromise

Converts a Promise to a folktale Future.

Signature

fromPromise(aPromise)
forall e, v: (Promise v e) => Future e v

Documentation

Converts a Promise to a folktale Future.

Note that this conversion may not be as accurate due to the differences in Promise and Future semantics. In particular, Promises recursively flatten any object with a .then method, and do not have a separate representation for cancellations.

If a Promise contains a rejection with Folktale's special Cancelled() value, then the resulting Future will be a cancelled Future rather than a rejected one.

Example:

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

fromPromise(Promise.resolve(1));
// => Future.resolve(1)

fromPromise(Promise.reject(1));
// => Future.reject(1)

Properties

Source Code

Defined in source/concurrency/future/_future.js at line 253, column 22
fromPromise(aPromise) {
    return require('folktale/conversions/promise-to-future')(aPromise);
  }
Stability
stable
Licence
MIT
Module
folktale/concurrency/future/_future
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)