Retrieves the value of a deferred as a Future.
Retrieves the value of a deferred as a Future.
future() {
let future = new (Future()); // eslint-disable-line prefer-const
this.listen({
onCancelled: _ => moveToState(future, Cancelled()),
onRejected: reason => moveToState(future, Rejected(reason)),
onResolved: value => moveToState(future, Resolved(value))
});
return future;
}