Introduces promise manager

This commit is contained in:
Frédéric Vachon 2015-03-31 16:36:20 -04:00
parent cd02870ab5
commit 125dc9545a
3 changed files with 31 additions and 3 deletions

View File

@ -87,10 +87,11 @@ module.exports = function (grunt) {
compress: {
files: [{
'<%= project.build %>/js/adagios.min.js' : [
'<%= project.app %>/app.js',
'<%= project.app %>/app.js',
'<%= project.app %>/components/config/config.js',
'<%= project.app %>/components/utils/promise_manager.js',
'<%= project.app %>/components/live/live.js',
'<%= project.app %>/components/live/notifications.js',
'<%= project.app %>/components/live/get_objects.js',
'<%= project.app %>/components/ng-justgage/ng-justgage.js',
'<%= project.app %>/components/filters/filters.js',
@ -135,8 +136,8 @@ module.exports = function (grunt) {
{
'<%= project.build %>/app.js': '<%= project.app %>/app.js',
'<%= project.build %>/components/config/config.js': '<%= project.app %>/components/config/config.js',
'<%= project.build %>/components/utils/promise_manager.js': '<%= project.app %>/components/utils/promise_manager.js',
'<%= project.build %>/components/live/live.js': '<%= project.app %>/components/live/live.js',
'<%= project.build %>/components/live/notifications.js': '<%= project.app %>/components/live/notifications.js',
'<%= project.build %>/components/live/get_objects.js': '<%= project.app %>/components/live/get_objects.js',
'<%= project.build %>/components/ng-justgage/ng-justgage.js': '<%= project.app %>/components/ng-justgage/ng-justgage.js',
'<%= project.build %>/components/filters/filters.js': '<%= project.app %>/components/filters/filters.js',
@ -177,8 +178,8 @@ module.exports = function (grunt) {
'<%= project.build %>/js/adagios.min.js' : [
'<%= project.build %>/app.js',
'<%= project.build %>/components/config/config.js',
'<%= project.build %>/components/utils/promise_manager.js',
'<%= project.build %>/components/live/live.js',
'<%= project.build %>/components/live/notifications.js',
'<%= project.build %>/components/live/get_objects.js',
'<%= project.build %>/components/ng-justgage/ng-justgage.js',
'<%= project.build %>/components/filters/filters.js',

View File

@ -16,6 +16,7 @@ angular.element(document).ready(function () {
angular.module('adagios', [
'ngRoute',
'adagios.config',
'adagios.utils.promiseManager',
'adagios.topbar',
'adagios.sidebar',
'adagios.host',

View File

@ -0,0 +1,26 @@
'use strict';
angular.module('adagios.utils.promiseManager', [])
.value('ajaxPromises', [])
.service('addAjaxPromise', ['ajaxPromises', function (ajaxPromises) {
return function (promise) {
ajaxPromises.push(promise);
};
}])
.service('clearAjaxPromises', ['$interval', 'ajaxPromises', function (ajaxPromises) {
return function ($interval) {
angular.forEach(ajaxPromises, function (promise) {
$interval.cancel(promise);
});
};
}])
.service('clearAllPromises', ['ajaxPromises', 'clearAjaxPromises',
function (ajaxPromises, clearAjaxPromises) {
return function () {
clearAjaxPromises();
};
}]);