-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set or get Async functions #76
Comments
Can you give an example? |
for example on browser function func (delay) {
return new Promise( r => setTimeout(r, delay) )
} async function test() {
await func( 1000 )
console.log( '1s passed' )
} if i were to define async function ( |
Are you trying to define an asynchronous function on the Java side? Currently not supported. |
is there any possibility of this getting |
If you want to define an asynchronous function on the Java side for use in JS, it's not supported yet. However, if you want to access an asynchronous function defined in JS from Java, you can refer to the following sample test code: @Test
public void testNativeCallWithAsyncFuncResult() {
QuickJSContext context = createContext();
context.evaluate("async function test() {return \"123\";}");
JSFunction test = context.getGlobalObject().getJSFunction("test");
JSObject promise = (JSObject) test.call();
JSFunction then = promise.getJSFunction("then");
JSObject ret = (JSObject) then.call((JSCallFunction) args -> {
System.out.println(args[0]);
return null;
});
ret.release();
then.release();
promise.release();
test.release();
context.destroy();
} |
why this ? the returned value is ret or args[0] then.call((JSCallFunction) args -> {
System.out.println(args[0]);
return null;
}); |
Sorry, I didn't understand what your question is. |
if the test function returns something, how and where do i retrive it? is it the |
It is arg[0], you can retrive it |
No description provided.
The text was updated successfully, but these errors were encountered: