Skip to content

Is there a way to register & call a rust async function from javascript? #34

Answered by andrieshiemstra
SreeniIO asked this question in Q&A
Discussion options

You must be logged in to vote

i modified the way EsValueFacade does get_promise_result, instead of making an async fn it now just return a Future (rust had an issue with &self still being borrowed because of the .await)

i altered your code so it does not create a new rt in the async method, that rt would be dropped at the end of that async method and behaviour would be unpredictable, in my unit test there is an example where i use a Weak ref to keep a ref to the original runtime.

Kind regards

use quickjs_runtime::esruntimebuilder::EsRuntimeBuilder;
use quickjs_runtime::esvalue::{EsValueConvertible, EsPromise};
use quickjs_runtime::esscript::EsScript;
use quickjs_runtime::esruntime::EsRuntime;
use std::sync::Arc;

#[ma…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@SreeniIO
Comment options

Comment options

You must be logged in to vote
1 reply
@andrieshiemstra
Comment options

Comment options

You must be logged in to vote
1 reply
@SreeniIO
Comment options

Answer selected by andrieshiemstra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants