rejected

Constructs a Task that resolves with a rejected 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

rejected(reason)
forall e, v: (e) => Task e v

Documentation

Constructs a Task that resolves with a rejected 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 { rejected } = require('folktale/concurrency/task');

try {
  const result = await rejected('hello').run().promise();
  throw 'never happens';
} catch (error) {
  $ASSERT(error == 'hello');
}

Properties

Source Code

Defined in source/concurrency/task/_task.js at line 367, column 20
rejected(reason) {
    return new Task(resolver => resolver.reject(reason));
  }
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/)