Closed jinguo-yin closed 1 week ago
When I use this code in main thread is OK!
i use async solve this program, code is: async(LedOn()) this function called yin coroutine will normal return when promise resolve ;
how to block execute in coroutine, :await() only valid in doFile lua code , when coroutine.create child, in child await can not resume.
I fixed it by wrapping the function I was calling in lua with async, and adding injectObjects and openingStandard Lib to createEngine
I use coroutine.create(func) create one coroutine, using :await() in func, when JS promise is resolved,but in coroutine' await() not return;
my code is: function LedFlashFunc() local isOn = true while true do wait(1000)
print('LedFlashFunc') if isOn then local result = LedOn():await() else LedOff():await() end isOn = not isOn end end
local co = coroutine.create(func) local succeed, result = coroutine.resume(co) if not succeed then print('LUA Error: ' .. tostring(result)) end