Skip to content

Instantly share code, notes, and snippets.

@wecc
Last active March 28, 2016 10:32
Show Gist options
  • Save wecc/3949b50170444af613df to your computer and use it in GitHub Desktop.
Save wecc/3949b50170444af613df to your computer and use it in GitHub Desktop.
import Ember from 'ember';
import { all, task, timeout } from 'ember-concurrency';
export default Ember.Route.extend({
serverStatusLoopTask: task(function *() {
let { servers } = this.modelFor('servers');
while (true) {
yield timeout(5 * 1000);
yield all(servers.map(::(this.get('fetchServerStatusTask')).perform));
}
}).on('activate').cancelOn('deactivate'),
fetchServerStatusTask: task(function *(server) {
yield server.belongsTo('status').reload();
}).maxConcurrency(3)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment