Javet
Javet copied to clipboard
Promise Listener不执行
JS代码:
function a(){
return new Promise((resolve, reject) => { resolve(1234); })
}
globalThis.main=a;
Java代码:
runtime.getExecutor(code).executeVoid();
var obj = runtime.getGlobalObject().invoke("main");
var callback = new AsyncHandler();
try (V8ValuePromise promise = (V8ValuePromise) obj) {
promise.register(callback);
runtime.await();
// The callback happens.
log("============>>>{}, {}", callback.getResult(), promise.getResult());
} finally {
runtime.lowMemoryNotification();
}
问题: callback 不执行。
There is a test case for this feature. As I just tested, it works as expected. Could you try that case out?