promiseToFuture<T> function

Future<T> promiseToFuture <T>(dynamic promise)

Implementation

Future<T> promiseToFuture<T>(promise) {
  var completer = new Completer<T>();
  var then = convertDartClosureToJS((r) => completer.complete(r), 1);
  var error = convertDartClosureToJS((e) => completer.completeError(e), 1);
  JS('', '#.then(#, #)', promise, then, error);
  return completer.future;
}