Hacker News new | ask | show | jobs
Building a JavaScript Promise from Scratch (medium.com)
2 points by ksashikumar 3162 days ago
1 comments

There is a subtle issue here: all parts of the suggested promise implementation run synchronously.

In spec-compliant promises, the executor runs synchronously [1][2], but the promise must wait until the next turn of the event loop [3] before calling the 'then' method.

[1] https://stackoverflow.com/questions/36726890/why-are-javascr...

[2] https://stackoverflow.com/questions/36932244/what-is-the-int...

[3] https://github.com/promises-aplus/promises-spec/issues/68