Should await yield same result each time ? Why not just use existing Promise library like this ?
MarcWeber opened this issue · 0 comments
MarcWeber commented
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 usescoroutine.wrap
instead of `Promise.spawn
but that requires tasks and some game engine..
Here is yet another implementation:
https://github.com/javalikescript/luajls