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

Implement promises support #15

Merged
merged 11 commits into from
Apr 5, 2021
Merged

Implement promises support #15

merged 11 commits into from
Apr 5, 2021

Conversation

ceifa
Copy link
Owner

@ceifa ceifa commented Apr 3, 2021

This PR is just a concept, the commented code should not be considered and will not be commented when it's done.

Related: #13

@ceifa ceifa mentioned this pull request Apr 3, 2021
@timstableford
Copy link
Contributor

I like the concept and awaiting all dangling promises makes sense. Doing something like this would allow Promise.all functionality. I've been thinking about how then and catch work in JS. When you call .catch or .then it actually returns a new promise eg

const o = Promise.resolve()
console.log(o === o.then(() => {}))

will print false.

I guess though it would be possible every time then or catch is called to push the new promise to the registry too

@ceifa ceifa changed the title Implement promises next function Implement promises next function [Draft] Apr 4, 2021
@ceifa ceifa marked this pull request as draft April 4, 2021 15:43
@ceifa
Copy link
Owner Author

ceifa commented Apr 4, 2021

I think I did some great things here, the API is simple and the JS-Lua bindings is pretty easy to understand, I used a lot of your code as base but removed some too. Would be nice to have your considerations @timstableford

src/thread.ts Outdated Show resolved Hide resolved
@timstableford
Copy link
Contributor

I think I did some great things here, the API is simple and the JS-Lua bindings is pretty easy to understand, I used a lot of your code as base but removed some too. Would be nice to have your considerations @timstableford

This is definitely a much simpler approach than mine. The lack of continuation function really helps

@ceifa ceifa marked this pull request as ready for review April 5, 2021 16:31
@ceifa ceifa changed the title Implement promises next function [Draft] Implement promises next function Apr 5, 2021
@ceifa ceifa changed the title Implement promises next function Implement promises support Apr 5, 2021
@ceifa ceifa merged commit 0de134c into main Apr 5, 2021
@ceifa ceifa changed the title Implement promises support Implement promises support #13 Apr 5, 2021
@ceifa ceifa changed the title Implement promises support #13 Implement promises support Apr 5, 2021
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

Successfully merging this pull request may close these issues.

2 participants