Skip to content

Instantly share code, notes, and snippets.

@kreshikhin
Created February 1, 2014 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kreshikhin/8756800 to your computer and use it in GitHub Desktop.
Save kreshikhin/8756800 to your computer and use it in GitHub Desktop.
// Promise to be filled with future value
var futureValue = new Promise();
// .then() will return a new promise
var anotherFutureValue = futureValue.then();
// Promise state handlers ( must be a function ).
// The returned value of the fulfilled / failed handler will be the value of the promise.
futureValue.then({
// Called if/when the promise is fulfilled
fulfilledHandler: function() {},
// Called if/when the promise fails
errorHandler: function() {},
// Called for progress events (not all implementations of promises have this)
progressHandler: function() {}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment