Created
August 24, 2014 16:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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