a zip code crypto-currency system good for red ONLY

AsyncScheduler.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /** PURE_IMPORTS_START .._Scheduler PURE_IMPORTS_END */
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b)
  4. if (b.hasOwnProperty(p))
  5. d[p] = b[p];
  6. function __() { this.constructor = d; }
  7. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8. };
  9. import { Scheduler } from '../Scheduler';
  10. export var AsyncScheduler = /*@__PURE__*/ (/*@__PURE__*/ function (_super) {
  11. __extends(AsyncScheduler, _super);
  12. function AsyncScheduler() {
  13. _super.apply(this, arguments);
  14. this.actions = [];
  15. /**
  16. * A flag to indicate whether the Scheduler is currently executing a batch of
  17. * queued actions.
  18. * @type {boolean}
  19. */
  20. this.active = false;
  21. /**
  22. * An internal ID used to track the latest asynchronous task such as those
  23. * coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and
  24. * others.
  25. * @type {any}
  26. */
  27. this.scheduled = undefined;
  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()); // exhaust the scheduler queue
  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));
  52. //# sourceMappingURL=AsyncScheduler.js.map