Download:
child 10:363ae86d0822
parent 8:39ac2486b9d3
9:8a7155aff782
Anton Shestakov <engored@ya.ru>, Thu, 27 Dec 2012 00:47:02 +0900
Abort all requests on workspace change.

1 файлов изменено, 18 вставок(+), 4 удалений(-) [+]
static/js/ui.js file | annotate | diff | comparison | revisions
--- a/static/js/ui.js Thu Dec 27 00:34:49 2012 +0900
+++ b/static/js/ui.js Thu Dec 27 00:47:02 2012 +0900
@@ -22,17 +22,31 @@
}
});
+ fruitbar.xhrs = [];
+ fruitbar.xhrs.abort = function() {
+ _(this).each(function(xhr) {
+ xhr.abort();
+ });
+
+ this.length = 0;
+ };
+
fruitbar.on('workspace', function(workspace) {
+ this.xhrs.abort();
+
this.tasks.url = '/' + encodeURIComponent(workspace) + '/tasks/';
this.projects.url = '/' + encodeURIComponent(workspace) + '/projects/';
- this.tasks.fetch();
- this.projects.fetch();
+ this.xhrs.push(this.tasks.fetch(), this.projects.fetch());
});
fruitbar.once('workspace', function() {
- window.setInterval(function() {fruitbar.projects.fetch({update: true});}, 60000);
- window.setInterval(function() {fruitbar.tasks.fetch({update: true});}, 60000);
+ window.setInterval(function() {
+ fruitbar.xhrs.push(fruitbar.tasks.fetch({update: true}));
+ }, 60000);
+ window.setInterval(function() {
+ fruitbar.xhrs.push(fruitbar.projects.fetch({update: true}));
+ }, 60000);
});
Backbone.history.start();