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 = new Promise(function(resolve,reject){ | |
/* | |
* Do things here (synchronous or asynchronous) | |
* some examples: | |
* -- run loops | |
* -- perform ajax requests | |
* -- count sheep! | |
*/ | |
if(some_desired_condition) | |
resolve(some_desired_arg) | |
else | |
reject(some_other_arg) | |
}); | |
promise.then(function(some_desired_arg){ | |
/* | |
* handle desired output | |
* other examples online might call this "Success" | |
*/ | |
}).catch(function(some_other_arg){ | |
/* | |
* handle other output | |
* other examples online might call this "Fail" | |
*/ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment