Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>These answers, including the selected answer, are good for introducing promises conceptually, but lacking in specifics of what exactly the differences are in the terminology that arises when using libraries implementing them (and there <strong>are</strong> important differences).</p> <p>Since it is still <a href="http://dom.spec.whatwg.org/#open-issues" rel="noreferrer">an evolving spec</a>, the answer currently comes from attempting to survey both references (like <a href="http://en.wikipedia.org/wiki/Futures_and_promises" rel="noreferrer">wikipedia</a>) and implementations (like <a href="http://api.jquery.com/category/deferred-object/" rel="noreferrer">jQuery</a>):</p> <ul> <li><p><strong>Deferred</strong>: Never described in popular references, <sup> <a href="http://en.wikipedia.org/wiki/Futures_and_promises" rel="noreferrer">1</a> <a href="https://github.com/promises-aplus/promises-spec" rel="noreferrer">2</a> <a href="http://dom.spec.whatwg.org/#promises" rel="noreferrer">3</a> <a href="https://github.com/domenic/promises-unwrapping/blob/master/README.md" rel="noreferrer">4</a> </sup> but commonly used by implementations as the arbiter of promise resolution (implementing <code>resolve</code> and <code>reject</code>). <sup> <a href="http://dojotoolkit.org/reference-guide/1.9/dojo/Deferred.html" rel="noreferrer">5</a> <a href="http://api.jquery.com/category/deferred-object/" rel="noreferrer">6</a> <a href="https://github.com/kriskowal/q" rel="noreferrer">7</a> </sup></p> <p>Sometimes deferreds are also promises (implementing <code>then</code>), <sup> <a href="http://dojotoolkit.org/reference-guide/1.9/dojo/Deferred.html" rel="noreferrer">5</a> <a href="http://api.jquery.com/category/deferred-object/" rel="noreferrer">6</a> </sup> other times it's seen as more pure to have the Deferred only capable of resolution, and forcing the user to access the promise for using <code>then</code>. <sup> <a href="https://github.com/kriskowal/q" rel="noreferrer">7</a> </sup></p></li> <li><p><strong>Promise</strong>: The most all-encompasing word for the strategy under discussion.</p> <p>A proxy object storing the result of a target function whose synchronicity we would like to abstract, plus exposing a <code>then</code> function accepting another target function and returning a new promise. <sup> <a href="https://github.com/promises-aplus/promises-spec" rel="noreferrer">2</a> </sup></p> <p>Example from <a href="http://wiki.commonjs.org/wiki/Promises/A" rel="noreferrer">CommonJS</a>:</p> <pre><code>&gt; asyncComputeTheAnswerToEverything() .then(addTwo) .then(printResult); 44 </code></pre> <p>&nbsp;</p> <p>Always described in popular references, although never specified as to whose responsibility resolution falls to. <sup> <a href="http://en.wikipedia.org/wiki/Futures_and_promises" rel="noreferrer">1</a> <a href="https://github.com/promises-aplus/promises-spec" rel="noreferrer">2</a> <a href="http://dom.spec.whatwg.org/#promises" rel="noreferrer">3</a> <a href="https://github.com/domenic/promises-unwrapping/blob/master/README.md" rel="noreferrer">4</a> </sup></p> <p>Always present in popular implementations, and never given resolution abilites. <sup> <a href="http://dojotoolkit.org/reference-guide/1.9/dojo/Deferred.html" rel="noreferrer">5</a> <a href="http://api.jquery.com/category/deferred-object/" rel="noreferrer">6</a> <a href="https://github.com/kriskowal/q" rel="noreferrer">7</a> </sup></p></li> <li><p><strong>Future</strong>: a seemingly deprecated term found in some popular references <sup> <a href="http://en.wikipedia.org/wiki/Futures_and_promises" rel="noreferrer">1</a> </sup> and at least one popular implementation, <sup> <a href="https://github.com/FuturesJS/FuturesJS" rel="noreferrer">8</a> </sup> but seemingly being phased out of discussion in preference for the term 'promise' <sup> <a href="http://dom.spec.whatwg.org/#promises" rel="noreferrer">3</a> </sup> and not always mentioned in popular introductions to the topic. <sup> <a href="http://books.google.com/books?id=0Fr_lxPGM6QC&amp;pg=PA174#v=onepage&amp;q&amp;f=false" rel="noreferrer">9</a> </sup></p> <p>However, at least one library uses the term generically for abstracting synchronicity and error handling, while not providing <code>then</code> functionality. <sup> <a href="https://github.com/angular/angular.js/blob/master/src/ngScenario/Future.js" rel="noreferrer">10</a> </sup> It's unclear if avoiding the term 'promise' was intentional, but probably a good choice since promises are built around 'thenables.' <sup> <a href="https://github.com/promises-aplus/promises-spec" rel="noreferrer">2</a> </sup></p></li> </ul> <h3>References</h3> <ol> <li><a href="http://en.wikipedia.org/wiki/Futures_and_promises" rel="noreferrer">Wikipedia on Promises &amp; Futures</a></li> <li><a href="http://promisesaplus.com/" rel="noreferrer">Promises/A+ spec</a></li> <li><a href="http://dom.spec.whatwg.org/#promises" rel="noreferrer">DOM Standard on Promises</a></li> <li><a href="https://github.com/domenic/promises-unwrapping/blob/master/README.md" rel="noreferrer">DOM Standard Promises Spec WIP</a></li> <li><a href="http://dojotoolkit.org/reference-guide/1.9/dojo/Deferred.html" rel="noreferrer">DOJO Toolkit Deferreds</a></li> <li><a href="http://api.jquery.com/category/deferred-object/" rel="noreferrer">jQuery Deferreds</a></li> <li><a href="https://github.com/kriskowal/q" rel="noreferrer">Q</a></li> <li><a href="https://github.com/FuturesJS/FuturesJS" rel="noreferrer">FutureJS</a></li> <li><a href="http://books.google.com/books?id=0Fr_lxPGM6QC&amp;pg=PA174#v=onepage&amp;q&amp;f=false" rel="noreferrer">Functional Javascript section on Promises</a></li> <li><a href="https://github.com/angular/angular.js/blob/master/src/ngScenario/Future.js" rel="noreferrer">Futures in AngularJS Integration Testing</a></li> </ol> <h3>Misc potentially confusing things</h3> <ul> <li><p><a href="http://promisesaplus.com/differences-from-promises-a" rel="noreferrer">Difference between Promises/A and Promises/A+</a></p> <p>(TL;DR, Promises/A+ mostly resolves ambiguities in Promises/A)</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload