rubyjs / mini_racer

Minimal embedded v8
MIT License
597 stars 93 forks source link

Calling async functions #145

Open joshleblanc opened 5 years ago

joshleblanc commented 5 years ago

Apologies for asking a question in issues, but there's no mini_racer tag on SO.

If I had an async function that I wanted to call from ruby, how would I do this?

Assuming my bundle correctly polyfills promises/async/await, and I have a function

async function asyncFunction() {
  await doSomething();
  return "thing";
}

Is it possible to call this from ruby, and return "thing"?

SamSaffron commented 5 years ago

Yeah looks like we don't have promise resolution in our interop layer so the value is hidden.

What you would need to do here have a non async function resolve the promise somehow and invoke the non async thing.

I am not against building some specific async promise interop but we don't have anything now

ianks commented 5 years ago

Were able to do this, although we have to resolve the promise in Ruby. Our promises may be polyfilled by Babel but I'm not sure exactly.

aspirisen commented 6 months ago

Hi, is there some update on this?