Transforms the successful value of a Future, without touching its state.
Transforms the successful value of a Future, without touching its state.
const { of, rejected } = require('folktale/concurrency/future');
of(1).map(x => x + 1).listen({
onResolved: (value) => $ASSERT(value == 2)
});
rejected(1).map(x => x + 1).listen({
onRejected: (value) => $ASSERT(value == 1)
});
map(transformation) {
return this.chain(value => Future.of(transformation(value)));
}