I don't know any equivalent, but I use code like this to have functionality:
var Poller = Ember.Object.extend({ _interval: 1000, _currentlyExecutedFunction: null, start: function(context, pollingFunction) { this.set('_currentlyExecutedFunction', this._schedule(context, pollingFunction, [].slice.call(arguments, 2))); }, stop: function() { Ember.run.cancel(this.get('_currentlyExecutedFunction')); }, _schedule: function(context, func, args) { return Ember.run.later(this, function() { this.set('_currentlyExecutedFunction', this._schedule(context, func, args)); func.apply(context, args); }, this.get('_interval')); }, setInterval: function(interval) { this.set('_interval', interval); } }); export default Poller;
Then you create an instance of poller: var poller = Poller.create() , and then you can play with poller.start() and poller.stop() +, setting the interval through poller.setInterval(interval) .
In my code, I did more or less like this (polling reports every 10 seconds):
_updateRunningReport: function(report) { var poller = new Poller(); poller.setInterval(this.POLLING_INTERVAL); poller.start(this, function() { if (report.isRunning()) { this._reloadReport(report); } else { poller.stop(); } }); eventBus.onLogout(function() { poller.stop(); }); },
Hope this helps ...
andrusieczko
source share