of

Constructs a Task that resolves with a successful value.

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

of(value)
forall e, v: (v) => Task e v

Documentation

Constructs a Task that resolves with a successful value.

The value is computed eagerly. If you need the value to be computed only when the task is ran you'll have to use the task function.

Example:

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

const result = await of('hello').run().promise();
$ASSERT(result == 'hello');

Properties

Source Code

Defined in source/concurrency/task/_task.js at line 365, column 20
of(value) {
    return new Task(resolver => resolver.resolve(value));
  }
Stability
experimental
Licence
MIT
Module
folktale/concurrency/task/_task
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)