[6a3a178] | 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 (b.hasOwnProperty(p)) d[p] = b[p]; };
|
---|
| 7 | return extendStatics(d, b);
|
---|
| 8 | }
|
---|
| 9 | return function (d, b) {
|
---|
| 10 | extendStatics(d, b);
|
---|
| 11 | function __() { this.constructor = d; }
|
---|
| 12 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
| 13 | };
|
---|
| 14 | })();
|
---|
| 15 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 16 | var Scheduler_1 = require("../Scheduler");
|
---|
| 17 | var AsyncScheduler = (function (_super) {
|
---|
| 18 | __extends(AsyncScheduler, _super);
|
---|
| 19 | function AsyncScheduler(SchedulerAction, now) {
|
---|
| 20 | if (now === void 0) { now = Scheduler_1.Scheduler.now; }
|
---|
| 21 | var _this = _super.call(this, SchedulerAction, function () {
|
---|
| 22 | if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
|
---|
| 23 | return AsyncScheduler.delegate.now();
|
---|
| 24 | }
|
---|
| 25 | else {
|
---|
| 26 | return now();
|
---|
| 27 | }
|
---|
| 28 | }) || this;
|
---|
| 29 | _this.actions = [];
|
---|
| 30 | _this.active = false;
|
---|
| 31 | _this.scheduled = undefined;
|
---|
| 32 | return _this;
|
---|
| 33 | }
|
---|
| 34 | AsyncScheduler.prototype.schedule = function (work, delay, state) {
|
---|
| 35 | if (delay === void 0) { delay = 0; }
|
---|
| 36 | if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
|
---|
| 37 | return AsyncScheduler.delegate.schedule(work, delay, state);
|
---|
| 38 | }
|
---|
| 39 | else {
|
---|
| 40 | return _super.prototype.schedule.call(this, work, delay, state);
|
---|
| 41 | }
|
---|
| 42 | };
|
---|
| 43 | AsyncScheduler.prototype.flush = function (action) {
|
---|
| 44 | var actions = this.actions;
|
---|
| 45 | if (this.active) {
|
---|
| 46 | actions.push(action);
|
---|
| 47 | return;
|
---|
| 48 | }
|
---|
| 49 | var error;
|
---|
| 50 | this.active = true;
|
---|
| 51 | do {
|
---|
| 52 | if (error = action.execute(action.state, action.delay)) {
|
---|
| 53 | break;
|
---|
| 54 | }
|
---|
| 55 | } while (action = actions.shift());
|
---|
| 56 | this.active = false;
|
---|
| 57 | if (error) {
|
---|
| 58 | while (action = actions.shift()) {
|
---|
| 59 | action.unsubscribe();
|
---|
| 60 | }
|
---|
| 61 | throw error;
|
---|
| 62 | }
|
---|
| 63 | };
|
---|
| 64 | return AsyncScheduler;
|
---|
| 65 | }(Scheduler_1.Scheduler));
|
---|
| 66 | exports.AsyncScheduler = AsyncScheduler;
|
---|
| 67 | //# sourceMappingURL=AsyncScheduler.js.map |
---|