TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

JavaScript Promises as EventEmitters

4 pointsby dmvaldmanabout 9 years ago

1 comment

hamburglarabout 9 years ago
I didn't actually read your code to see if you account for this, but one problem with this simplification, at least the very brief "that's it" description, is the fact that promises may be resolved before you hook up the thing receiving the callback. In other words, the case where you say .addEventListener but the event had already fired.