| 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.AsyncScheduler = void 0; |
| 19 |
var Scheduler_1 = require("../Scheduler"); |
| 20 |
var AsyncScheduler = (function (_super) { |
| 21 |
__extends(AsyncScheduler, _super); |
| 22 |
function AsyncScheduler(SchedulerAction, now) { |
| 23 |
if (now === void 0) { now = Scheduler_1.Scheduler.now; } |
| 24 |
var _this = _super.call(this, SchedulerAction, now) || this; |
| 25 |
_this.actions = []; |
| 26 |
_this._active = false; |
| 27 |
return _this; |
| 28 |
} |
| 29 |
AsyncScheduler.prototype.flush = function (action) { |
| 30 |
var actions = this.actions; |
| 31 |
if (this._active) { |
| 32 |
actions.push(action); |
| 33 |
return; |
| 34 |
} |
| 35 |
var error; |
| 36 |
this._active = true; |
| 37 |
do { |
| 38 |
if ((error = action.execute(action.state, action.delay))) { |
| 39 |
break; |
| 40 |
} |
| 41 |
} while ((action = actions.shift())); |
| 42 |
this._active = false; |
| 43 |
if (error) { |
| 44 |
while ((action = actions.shift())) { |
| 45 |
action.unsubscribe(); |
| 46 |
} |
| 47 |
throw error; |
| 48 |
} |
| 49 |
}; |
| 50 |
return AsyncScheduler; |
| 51 |
}(Scheduler_1.Scheduler)); |
| 52 |
exports.AsyncScheduler = AsyncScheduler; |
| 53 |
//# sourceMappingURL=AsyncScheduler.js.map |