Difference between revisions of "Futures and promises"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(External links)
(See also)
 
(9 intermediate revisions by the same user not shown)
Line 18: Line 18:
  
 
* [[jQuery Deferred object]]
 
* [[jQuery Deferred object]]
 +
* [[Promise object (JavaScript)]]
 +
* [[Observer pattern]]
  
 
== External links ==
 
== External links ==
Line 23: Line 25:
 
* [https://en.wikipedia.org/wiki/Futures_and_promises Futures and promises] @ Wikipedia.org  
 
* [https://en.wikipedia.org/wiki/Futures_and_promises Futures and promises] @ Wikipedia.org  
 
* [https://www.promisejs.org/ Promises] by Forbes Lindesay
 
* [https://www.promisejs.org/ Promises] by Forbes Lindesay
 +
* [http://blogs.fluidinfo.com/terry/2013/09/12/promises-are-first-class-objects-for-function-calls/ Promises are first-class objects for function calls] by Terry Jones
 +
* [https://promisesaplus.com/implementations Conformant Implementations] @ promisesaplus.com
  
 +
== Sinon.js ==
  
 +
* [http://jonnyreeves.co.uk/2012/stubbing-javascript-promises-with-sinonjs/ Stubbing JavaScript Promises with SinonJS] by Jonny Reeves
 +
 +
=== when.js ===
 +
 +
* [http://www.carlosble.com/2013/03/unit-testing-javascript-with-promises-and-jasmine/ Unit testing JavaScript with Promises and Jasmine]
  
 
[[Category:Computer programming]]
 
[[Category:Computer programming]]
 
[[Category:Computer science]]
 
[[Category:Computer science]]
[[Category:Computing]]
+
[[Category: JavaScript promises]]

Latest revision as of 14:23, 2 January 2017

In computer science, future, promise, delay, and deferred refer to constructs used for synchronizing program execution in some concurrent programming languages.

They describe an object that acts as a proxy for a result that is initially unknown, usually because the computation of its value is yet incomplete.

Description

The term promise was proposed in 1976 by Daniel P. Friedman and David Wise; Peter Hibbard called it eventual.

A somewhat similar concept future was introduced in 1977 in a paper by Henry Baker and Carl Hewitt.

The terms future, promise, delay, and deferred are often used interchangeably, although some differences in usage between future and promise are treated below. Specifically, when usage is distinguished, a future is a read-only placeholder view of a variable, while a promise is a writable, single assignment container which sets the value of the future.

Notably, a future may be defined without specifying which specific promise will set its value, and different possible promises may set the value of a given future, though this can be done only once for a given future.

In other cases a future and a promise are created together and associated with each other: the future is the value, the promise is the function that sets the value – essentially the return value (future) of an asynchronous function (promise). Setting the value of a future is also called resolving, fulfilling, or binding it.

See also

External links

Sinon.js

when.js