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
function connectAndPrint() { | |
// our promise chain | |
connect().then(function() { | |
return print(); | |
}).then(function() { | |
success(); // exceptions get thrown all the way up the stack | |
}).catch(fail); // so one catch is often enough for all promises | |
// NOTE: If a function returns a promise, you don't need to wrap it in a fuction call. | |
// The following is perfectly valid: |