mirror of
https://github.com/moodle/moodle.git
synced 2025-07-05 22:46:33 +02:00
- No longer use the Fibonacci sequence for delaying the timeout. It is too aggressive. - The backoff_timer AMD module now expects the callback AND the backoff function to be passed to the constructor. - Added ability to specify polling frequency in config.php. - Added helper function to return the cache key. - Reworded the parameters for clarity.
1 line
808 B
JavaScript
1 line
808 B
JavaScript
define(function(){var a=function(a,b){this.callback=a,this.backOffFunction=b};return a.prototype.callback=null,a.prototype.backOffFunction=null,a.prototype.time=null,a.prototype.timeout=null,a.prototype.generateNextTime=function(){var a=this.backOffFunction(this.time);return this.time=a,a},a.prototype.reset=function(){return this.time=null,this.stop(),this},a.prototype.stop=function(){return this.timeout&&(window.clearTimeout(this.timeout),this.timeout=null),this},a.prototype.start=function(){if(!this.timeout){var a=this.generateNextTime();this.timeout=window.setTimeout(function(){this.callback(),this.stop(),this.start()}.bind(this),a)}return this},a.prototype.restart=function(){return this.reset().start()},a.getIncrementalCallback=function(a,b,c,d){return function(e){return e?e+b>c?d:e+b:a}},a}); |