Update Async.java

pull/149/head
FongMi 3 years ago
parent 7ceeb13eeb
commit dd2e272c46
  1. 7
      quickjs/src/main/java/com/fongmi/quickjs/method/Async.java

@ -22,8 +22,8 @@ public class Async {
JSFunction function = object.getJSFunction(name);
if (function == null) return empty();
Object result = function.call(args);
if (result instanceof JSObject) return then(result);
future.complete(result);
if (result instanceof JSObject) then(result);
else future.complete(result);
return future;
}
@ -32,11 +32,10 @@ public class Async {
return future;
}
private CompletableFuture<Object> then(Object result) {
private void then(Object result) {
JSObject promise = (JSObject) result;
JSFunction then = promise.getJSFunction("then");
if (then != null) then.call(callback);
return future;
}
private final JSCallFunction callback = new JSCallFunction() {

Loading…
Cancel
Save