AsapScheduler.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var AsyncScheduler_1 = require('./AsyncScheduler');
  8. var AsapScheduler = (function (_super) {
  9. __extends(AsapScheduler, _super);
  10. function AsapScheduler() {
  11. _super.apply(this, arguments);
  12. }
  13. AsapScheduler.prototype.flush = function (action) {
  14. this.active = true;
  15. this.scheduled = undefined;
  16. var actions = this.actions;
  17. var error;
  18. var index = -1;
  19. var count = actions.length;
  20. action = action || actions.shift();
  21. do {
  22. if (error = action.execute(action.state, action.delay)) {
  23. break;
  24. }
  25. } while (++index < count && (action = actions.shift()));
  26. this.active = false;
  27. if (error) {
  28. while (++index < count && (action = actions.shift())) {
  29. action.unsubscribe();
  30. }
  31. throw error;
  32. }
  33. };
  34. return AsapScheduler;
  35. }(AsyncScheduler_1.AsyncScheduler));
  36. exports.AsapScheduler = AsapScheduler;
  37. //# sourceMappingURL=AsapScheduler.js.map