Skip to content

Instantly share code, notes, and snippets.

@lukemelia
Created August 24, 2014 16:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukemelia/0ab0ebe7644789afd66e to your computer and use it in GitHub Desktop.
Save lukemelia/0ab0ebe7644789afd66e to your computer and use it in GitHub Desktop.
Example of fetching json every 5 seconds and updating a route's controller with it
Pd3.IndexRoute = Ember.Route.extend({
activate: function(){
var route = this;
this.recurringFetchId = window.setInterval(function() {
Ember.$.getJSON('/s/1.json').then(function(json){
Ember.run(function(){
route.controller.set('model', json);
});
});
}, 5*1000);
},
deactivate: function(){
window.clearInterval(this.recurringFetchId);
},
model: function(params) {
return Ember.$.getJSON('/s/1.json');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment