A simple image loader
Load image:
var Imageloader = require('stupid-imageloader');
var imageloader = Imageloader();
imageloader.load('image.jpg') // returns a promise (stupid-deferred)
.success(function(image){
// Do something
})
.error(function(){
// Do something
});
Chain loading events:
imageloader.load('image.jpg') // returns a promise (stupid-deferred)
.then(function(){
// On success
return imageloader.load('new-image.jpg');
}, function(){
// On error
})
.then(function(){
return imageloader.load('another-new-image.jpg');
})
.then(function(){
// All 3 images is loaded after each other
});