Last active
December 21, 2015 15:19
-
-
Save bsturdivan/6325593 to your computer and use it in GitHub Desktop.
Promises.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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