From c2404a22f4642b3467bbb5cc7ab5dde2526820ce Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Sun, 13 Jul 2014 18:02:09 -0700 Subject: [PATCH] add polling for developer view --- planetstack/core/xoslib/static/js/xosDeveloper.js | 2 +- planetstack/core/xoslib/static/js/xoslib/xos-backbone.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/planetstack/core/xoslib/static/js/xosDeveloper.js b/planetstack/core/xoslib/static/js/xosDeveloper.js index eb83efe..6ea2d59 100644 --- a/planetstack/core/xoslib/static/js/xosDeveloper.js +++ b/planetstack/core/xoslib/static/js/xosDeveloper.js @@ -33,7 +33,7 @@ DeveloperApp.on("start", function() { }); console.log(developerSliceListView); DeveloperApp.mainRegion.show(developerSliceListView); - xos.slicesPlus.fetch(); + xos.slicesPlus.startPolling(); //fetch(); }); $(document).ready(function(){ diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js index 59645e7..fe918ea 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js +++ b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js @@ -51,6 +51,15 @@ XOSCollection = Backbone.Collection.extend({ return this.models.map(function(element) { return element.attributes; }); }, + startPolling: function() { + if (!this._polling) { + collection=this; + setInterval(function() { console.log(collection); collection.fetch(); }, 10000); + this._polling=true; + this.fetch(); + } + }, + maybeFetch: function(options){ // Helper function to fetch only if this collection has not been fetched before. if(this._fetched){ -- 2.43.0