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 (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
9 return function (d, b) {
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15 Object.defineProperty(exports, "__esModule", { value: true });
16 var Immediate_1 = require("../util/Immediate");
17 var AsyncAction_1 = require("./AsyncAction");
18 var AsapAction = (function (_super) {
19 __extends(AsapAction, _super);
20 function AsapAction(scheduler, work) {
21 var _this = _super.call(this, scheduler, work) || this;
22 _this.scheduler = scheduler;
26 AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
27 if (delay === void 0) { delay = 0; }
28 if (delay !== null && delay > 0) {
29 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
31 scheduler.actions.push(this);
32 return scheduler.scheduled || (scheduler.scheduled = Immediate_1.Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
34 AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
35 if (delay === void 0) { delay = 0; }
36 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
37 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
39 if (scheduler.actions.length === 0) {
40 Immediate_1.Immediate.clearImmediate(id);
41 scheduler.scheduled = undefined;
46 }(AsyncAction_1.AsyncAction));
47 exports.AsapAction = AsapAction;
48 //# sourceMappingURL=AsapAction.js.map