Skip to content

Instantly share code, notes, and snippets.

@vojtatranta
Last active May 3, 2016 22:10
Show Gist options
  • Save vojtatranta/316c6e7acb556b20207ed16be4ee0356 to your computer and use it in GitHub Desktop.
Save vojtatranta/316c6e7acb556b20207ed16be4ee0356 to your computer and use it in GitHub Desktop.
Promise hell
// 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