Last active
May 3, 2016 22:10
-
-
Save vojtatranta/316c6e7acb556b20207ed16be4ee0356 to your computer and use it in GitHub Desktop.
Promise hell
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
// promise hell | |
ImageProcessor.prototype.execResizeImage = function ImageProcessor_execResizeImage(option, imageData) { | |
return new Promise(function(resolve, reject) { | |
var resizer = new ImageResizer(option.size); | |
resizer.exec(imageData) | |
.then(function(resizedImage) { | |
var reducer = new ImageReducer(option); | |
reducer.exec(resizedImage) | |
.then(function(reducedImage) { | |
resolve(reducedImage); | |
}) | |
.catch(function(message) { | |
reject(message); | |
}); | |
.catch(function(message) { | |
reject(message); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment