recover

Transforms a failed future into a new future.

Deprecated since undefined

Signature

value(handler)
(Future 'f 's).(('f) => Future 'f2 's2) => Future 'f2 's

Documentation

Transforms a failed future into a new future.

Example:

const { rejected, of } = require('folktale/concurrency/future');

of(1).recover(x => of(x + 1)).listen({
  onResolved: (value) => $ASSERT(value == 1)
});

rejected(1).recover(x => of(x + 1)).listen({
  onResolved: (value) => $ASSERT(value == 2)
});

rejected(1).recover(x => rejected(x + 1)).listen({
  onRejected: (value) => $ASSERT(value == 2)
});

Properties

Source Code

Defined in source/concurrency/future/_future.js at line 24, column 0
recover(handler) {
    warnDeprecation('`.recover` was renamed to `.orElse` for consistency, and thus `.recover(handler)` is deprecated. Use `.orElse(handler)` instead.');
    return this.orElse(handler);
  }
Stability
deprecated
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/)