AsapAction.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.AsapAction = void 0;
  19. var AsyncAction_1 = require("./AsyncAction");
  20. var immediateProvider_1 = require("./immediateProvider");
  21. var AsapAction = (function (_super) {
  22. __extends(AsapAction, _super);
  23. function AsapAction(scheduler, work) {
  24. var _this = _super.call(this, scheduler, work) || this;
  25. _this.scheduler = scheduler;
  26. _this.work = work;
  27. return _this;
  28. }
  29. AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  30. if (delay === void 0) { delay = 0; }
  31. if (delay !== null && delay > 0) {
  32. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  33. }
  34. scheduler.actions.push(this);
  35. return scheduler._scheduled || (scheduler._scheduled = immediateProvider_1.immediateProvider.setImmediate(scheduler.flush.bind(scheduler, undefined)));
  36. };
  37. AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
  38. var _a;
  39. if (delay === void 0) { delay = 0; }
  40. if (delay != null ? delay > 0 : this.delay > 0) {
  41. return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
  42. }
  43. var actions = scheduler.actions;
  44. if (id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) {
  45. immediateProvider_1.immediateProvider.clearImmediate(id);
  46. if (scheduler._scheduled === id) {
  47. scheduler._scheduled = undefined;
  48. }
  49. }
  50. return undefined;
  51. };
  52. return AsapAction;
  53. }(AsyncAction_1.AsyncAction));
  54. exports.AsapAction = AsapAction;
  55. //# sourceMappingURL=AsapAction.js.map