lua-async-await icon indicating copy to clipboard operation
lua-async-await copied to clipboard

Should await yield same result each time ? Why not just use existing Promise library like this ?

Open MarcWeber opened this issue 2 years ago • 0 comments
trafficstars

If you come from JS world you expect await to await a promise. Thus awaiting multiple times should yield the same result. A mature promise library seems to be this. There are more on github:

https://eryn.io/roblox-lua-promise/docs/WhyUsePromises

const wrap = (f) => (...args) => new Promise((r,j) => f(args, (e,r) => { if (err) j(err); r(r) }))

And that wrapper already exists from changelog:

  • Promise.promisify now uses coroutine.wrap instead of `Promise.spawn

but that requires tasks and some game engine..

Here is yet another implementation: https://github.com/javalikescript/luajls

MarcWeber avatar Mar 31 '23 17:03 MarcWeber