Skip to content

Instantly share code, notes, and snippets.

@bsturdivan
Last active December 21, 2015 15:19
Show Gist options
  • Save bsturdivan/6325593 to your computer and use it in GitHub Desktop.
Save bsturdivan/6325593 to your computer and use it in GitHub Desktop.
Promises.js
var Promise = function() {
var response = null,
successCallback = null;
return {
resolve: function(value) {
response = value;
if(successCallback) {
successCallback(response);
successCallback = null;
}
},
success: function(callback) {
if(!response) {
successCallback = callback;
} else {
callback(response);
}
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment