AsyncScheduler.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { __extends } from "tslib";
  2. import { Scheduler } from '../Scheduler';
  3. var AsyncScheduler = (function (_super) {
  4. __extends(AsyncScheduler, _super);
  5. function AsyncScheduler(SchedulerAction, now) {
  6. if (now === void 0) { now = Scheduler.now; }
  7. var _this = _super.call(this, SchedulerAction, now) || this;
  8. _this.actions = [];
  9. _this._active = false;
  10. return _this;
  11. }
  12. AsyncScheduler.prototype.flush = function (action) {
  13. var actions = this.actions;
  14. if (this._active) {
  15. actions.push(action);
  16. return;
  17. }
  18. var error;
  19. this._active = true;
  20. do {
  21. if ((error = action.execute(action.state, action.delay))) {
  22. break;
  23. }
  24. } while ((action = actions.shift()));
  25. this._active = false;
  26. if (error) {
  27. while ((action = actions.shift())) {
  28. action.unsubscribe();
  29. }
  30. throw error;
  31. }
  32. };
  33. return AsyncScheduler;
  34. }(Scheduler));
  35. export { AsyncScheduler };
  36. //# sourceMappingURL=AsyncScheduler.js.map