Sunday, August 12, 2018

Promise Pattern

Promise Pattern

Asynchronous programming technique in JavaScript named “Promises” which is a pattern in CommonJS, WinJS/Win8, and jQuery Deferred. Promises can be chained as with jQuery. A promise represents the result of a potentially long running and not necessarily complete operation. Instead of blocking and waiting for the long-running computation to complete, the pattern returns an object which represents the promised result. A promise implements a method for registering callbacks for state change notifications, commonly named the ‘then’ method:
 
var results = searchTwitter(term).then(filterResults);
displayResults(results);
 
 

No comments:

Post a Comment