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.

Promises/A+

61 pointsby Dekkualmost 12 years ago

12 comments

domenicdalmost 12 years ago
It&#x27;s worth noting we are <i>very</i> close to finishing up a 1.1 revision of the spec, which clarifies a few things mainly around how promise libraries interoperate with each other&#x27;s promises. You can find the work in our master branch (as opposed to gh-pages):<p><a href="https://github.com/promises-aplus/promises-spec" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;promises-aplus&#x2F;promises-spec</a><p>Including a changelog:<p><a href="https://github.com/promises-aplus/promises-spec/blob/master/changelog.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;promises-aplus&#x2F;promises-spec&#x2F;blob&#x2F;master&#x2F;...</a><p>And the issues still open versus closed in the 1.1 timeframe are at<p><a href="https://github.com/promises-aplus/promises-spec/issues?milestone=2&amp;page=1&amp;state=open" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;promises-aplus&#x2F;promises-spec&#x2F;issues?miles...</a><p>We were hoping to do a revision of the website&#x27;s look at the time of the 1.1 release as well, mainly adding links to additional resources in the repository (like the implementations list, credits, etc.). A bit sad that we haven&#x27;t moved fast enough to finish that before making the front page of Hacker News!
SeanDavalmost 12 years ago
I have just started doing development in Node.js. Originally using the excellent caolan&#x2F;async library (<a href="https://github.com/caolan/async" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;caolan&#x2F;async</a>) for handling synchronous situations. Now started moving towards Promises but finding it quite hard to locate any &quot;Promises for Dummies&quot; type guide. Most of the libraries like &quot;q&quot; etc (<a href="https://github.com/kriskowal/q" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kriskowal&#x2F;q</a>) just give you a list of functions to use and related syntax but I have yet to come across a guide that goes into detail as to exactly how and why you use certain functions.<p>I am kind of figuring things out as I go along but if anyone here can point me to such guides, I would be most grateful.
评论 #6009208 未加载
评论 #6009449 未加载
评论 #6009394 未加载
评论 #6009994 未加载
_greim_almost 12 years ago
My beef with JS Promises (uppercase &quot;P&quot;) is that, as a programming idiom, I prefer <i>once I have X, Y and Z, do something with X, Y and Z</i> over <i>get X, then get Y, then get Z</i>. In the former case, the provisioning logic is a separate concern; it could be done in parallel, serially, or via some combination of both. In the latter case, it&#x27;s inherently serial.<p>I wrote an alternate implementation of promises in JS (lowercase &quot;p&quot;) that uses the former approach: <a href="https://github.com/greim/await.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;greim&#x2F;await.js</a>
评论 #6009166 未加载
评论 #6009087 未加载
评论 #6009073 未加载
评论 #6009105 未加载
tjansenalmost 12 years ago
The great thing about Promises&#x2F;A+ is that it&#x27;s so small. I have implemented it in 375 bytes, and was even able to add two convenience functions: <a href="https://github.com/timjansen/PinkySwear.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;timjansen&#x2F;PinkySwear.js</a>
评论 #6009630 未加载
domenicdalmost 12 years ago
I gave a talk at JSConf US 2013 about the genesis of this spec, and how I believe it plays into the future of open, developer-driven APIs for the web platform. I hope the video is up soon, but until then, the slides are at <a href="http://www.slideshare.net/domenicdenicola/boom-promisesa-was-born" rel="nofollow">http:&#x2F;&#x2F;www.slideshare.net&#x2F;domenicdenicola&#x2F;boom-promisesa-was...</a>
martingordonalmost 12 years ago
Maybe I&#x27;m missing something, but I find C#&#x27;s async&#x2F;await much more intuitive (not having written any C# and currently working on a pet project using promises with Node and Q).<p>My issue with promises is that I find myself working around the API&#x2F;language when I actually want synchronous code. My app calls a JSON API and then writes the results to three tables (in sequence). In &quot;normal&quot;, blocking code:<p><pre><code> results = getResults(); writeTable1(results.foo); writeTable2(results.bar); writeTable3(results.baz); </code></pre> Using Node and Q:<p><pre><code> db.load().then(()-&gt; setupDB(db)).then(()-&gt; collectData(db)).done() </code></pre> In which setupDB() returns a chain of three promises and collectData, which loops through the results and attach a new promise to the chain in order to return a chain of `n` promises.<p>Are these just growing pains of learning a new paradigm or am I using the wrong tool for the job?<p>Can someone point me to any projects that actually use promises?
评论 #6012255 未加载
评论 #6012917 未加载
kolodnyalmost 12 years ago
I wrote a library a while ago that nearly fulfills this entire spec. I&#x27;ve added&#x2F;changed things that I thought were more intuitive. <a href="https://github.com/kolodny/wttt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kolodny&#x2F;wttt</a>
评论 #6010637 未加载
willvarfaralmost 12 years ago
&gt; 3.2.1.1 If onFulfilled is not a function, it must be ignored.<p>This is idiomatic JS I guess, but it bugs me to bits. IMO the parameter should be a function or it should be null; anything else should throw an error.
评论 #6010090 未加载
unwiredbenalmost 12 years ago
Thanks for this discussion... after reading Domenic&#x27;s slides, watching his talk, and going through the questions here and on the gist, I&#x27;ve filed a bug to try to move Enyo&#x27;s async implementation to promises after our next release. (<a href="https://enyojs.atlassian.net/browse/ENYO-2700" rel="nofollow">https:&#x2F;&#x2F;enyojs.atlassian.net&#x2F;browse&#x2F;ENYO-2700</a>) Currently, our code is more like the jQuery 1.5 implementation, but it really lacks the nice error semantics that Promises&#x2F;A+ has.
andrewcookealmost 12 years ago
wouldn&#x27;t it be good to explain somewhere, early on, that this is for javascript?
评论 #6009192 未加载
评论 #6009196 未加载
评论 #6009107 未加载
ricardobeatalmost 12 years ago
Promises are coming of age too late, and still have unsolved fundamental issues.<p>Meanwhile, ES6 generators are coming to node v0.12, already in FF and soon to be in Chrome; <i>that</i> is a whole different game.
评论 #6010506 未加载
pspeter3almost 12 years ago
Just out of curiosity, why don&#x27;t we use node&#x27;s event emitters to wrap callbacks as promises?
评论 #6010613 未加载