AsapScheduler.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.AsapScheduler = void 0;
  19. var AsyncScheduler_1 = require("./AsyncScheduler");
  20. var AsapScheduler = (function (_super) {
  21. __extends(AsapScheduler, _super);
  22. function AsapScheduler() {
  23. return _super !== null && _super.apply(this, arguments) || this;
  24. }
  25. AsapScheduler.prototype.flush = function (action) {
  26. this._active = true;
  27. var flushId = this._scheduled;
  28. this._scheduled = undefined;
  29. var actions = this.actions;
  30. var error;
  31. action = action || actions.shift();
  32. do {
  33. if ((error = action.execute(action.state, action.delay))) {
  34. break;
  35. }
  36. } while ((action = actions[0]) && action.id === flushId && actions.shift());
  37. this._active = false;
  38. if (error) {
  39. while ((action = actions[0]) && action.id === flushId && actions.shift()) {
  40. action.unsubscribe();
  41. }
  42. throw error;
  43. }
  44. };
  45. return AsapScheduler;
  46. }(AsyncScheduler_1.AsyncScheduler));
  47. exports.AsapScheduler = AsapScheduler;
  48. //# sourceMappingURL=AsapScheduler.js.map