QueueAction.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.QueueAction = void 0;
  19. var AsyncAction_1 = require("./AsyncAction");
  20. var QueueAction = (function (_super) {
  21. __extends(QueueAction, _super);
  22. function QueueAction(scheduler, work) {
  23. var _this = _super.call(this, scheduler, work) || this;
  24. _this.scheduler = scheduler;
  25. _this.work = work;
  26. return _this;
  27. }
  28. QueueAction.prototype.schedule = function (state, delay) {
  29. if (delay === void 0) { delay = 0; }
  30. if (delay > 0) {
  31. return _super.prototype.schedule.call(this, state, delay);
  32. }
  33. this.delay = delay;
  34. this.state = state;
  35. this.scheduler.flush(this);
  36. return this;
  37. };
  38. QueueAction.prototype.execute = function (state, delay) {
  39. return delay > 0 || this.closed ? _super.prototype.execute.call(this, state, delay) : this._execute(state, delay);
  40. };
  41. QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  42. if (delay === void 0) { delay = 0; }
  43. if ((delay != null && delay > 0) || (delay == null && this.delay > 0)) {
  44. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  45. }
  46. scheduler.flush(this);
  47. return 0;
  48. };
  49. return QueueAction;
  50. }(AsyncAction_1.AsyncAction));
  51. exports.QueueAction = QueueAction;
  52. //# sourceMappingURL=QueueAction.js.map