Closed jude90 closed 1 year ago
I think I just found the way. I am still unsure if there is any problem with this approach, just wanted to share with you:
await lua.doString(`
co = coroutine.create(function ()
print("hi")
end)
`)
const co = lua.global.get('co');
lua.global.get('coroutine').resume(co)
You don't need to get entire coroutine
object, since wasmoon already converts a coroutine to a thread object:
await lua.doString(`
co = coroutine.create(function ()
print("hi")
end)
`)
const co = lua.global.get('co');
const { result, resultCount } = co.resume(0)
I wrote a lua function with yield , then create a coroutine in lua . Now I want to execute it step by step (yield by yield) in javascript , how should I do this job ?