Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MarcWeber opened this issue Mar 31, 2023 · 0 comments

Comments

@MarcWeber
Copy link

MarcWeber commented Mar 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant