UI for Zipcoin Blue

QueueAction.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var AsyncAction_1 = require('./AsyncAction');
  8. /**
  9. * We need this JSDoc comment for affecting ESDoc.
  10. * @ignore
  11. * @extends {Ignored}
  12. */
  13. var QueueAction = (function (_super) {
  14. __extends(QueueAction, _super);
  15. function QueueAction(scheduler, work) {
  16. _super.call(this, scheduler, work);
  17. this.scheduler = scheduler;
  18. this.work = work;
  19. }
  20. QueueAction.prototype.schedule = function (state, delay) {
  21. if (delay === void 0) { delay = 0; }
  22. if (delay > 0) {
  23. return _super.prototype.schedule.call(this, state, delay);
  24. }
  25. this.delay = delay;
  26. this.state = state;
  27. this.scheduler.flush(this);
  28. return this;
  29. };
  30. QueueAction.prototype.execute = function (state, delay) {
  31. return (delay > 0 || this.closed) ?
  32. _super.prototype.execute.call(this, state, delay) :
  33. this._execute(state, delay);
  34. };
  35. QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
  36. if (delay === void 0) { delay = 0; }
  37. // If delay exists and is greater than 0, or if the delay is null (the
  38. // action wasn't rescheduled) but was originally scheduled as an async
  39. // action, then recycle as an async action.
  40. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  41. return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
  42. }
  43. // Otherwise flush the scheduler starting with this action.
  44. return scheduler.flush(this);
  45. };
  46. return QueueAction;
  47. }(AsyncAction_1.AsyncAction));
  48. exports.QueueAction = QueueAction;
  49. //# sourceMappingURL=QueueAction.js.map