Transforms a failed future into a new future.
Transforms a failed future into a new future.
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)
});
recover(handler) {
warnDeprecation('`.recover` was renamed to `.orElse` for consistency, and thus `.recover(handler)` is deprecated. Use `.orElse(handler)` instead.');
return this.orElse(handler);
}