second-state / wasmedge-quickjs

A high-performance, secure, extensible, and OCI-complaint JavaScript runtime for WasmEdge.
Apache License 2.0
477 stars 59 forks source link

How to support asynchronous processing in JsFn::call ? #98

Open gudaoxuri opened 1 year ago

gudaoxuri commented 1 year ago

Hi,

I want to call rust's asynchronous processing logic in js (such as hyper_wasi project's asynchronous httpclient), how should I handle it?

struct HttpGetFn;
impl JsFn for HttpGetFn {
    fn call(ctx: &mut Context, _this_val: JsValue, argv: &[JsValue]) -> JsValue {
        // How to support asynchronous processing? like:
        // let resp = http_req(...).await;
    }
}