webui-aria2/js/services/alerts.js
2013-03-02 12:01:07 +01:00

22 lines
535 B
JavaScript

angular.module('webui.services.alerts', ['webui.services.deps'])
.factory('$alerts', ['$_', function(_) {
var alerters = [];
return {
addAlert: function() {
var args = Array.prototype.slice.call(arguments, 0);
setTimeout(function() {
_.each(alerters, function(alt) {
alt.apply({}, args);
});
}, 0);
},
addAlerter: function(cb) {
alerters.push(cb);
},
// a simple function for debugging
log: function(msg) {
this.addAlert(msg, 'info');
}
};
}]);