fromPromised

Converts a Promise-yielding function to a Task-yielding function.

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.

Signature

fromPromised(aPromiseFn)
forall e, v:
  ((Any...) => Promise v e) => (Any...) => Task e v

Documentation

Converts a Promise-yielding function to a Task-yielding function.

Example:

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

function delay(ms) {
  return new Promise((resolve) => {
    setTimeout(() => resolve(ms), ms)
  });
}

const delayT = fromPromised(delay);

await delayT(10).run().promise();
// resolves after 10ms

Properties

Source Code

Defined in source/concurrency/task/index.js at line 17, column 17
fromPromised(aPromiseFn) {
    return require('folktale/conversions/promised-to-task')(aPromiseFn);
  }
Stability
experimental
Licence
MIT
Module
folktale/concurrency/task
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)