a zip code crypto-currency system good for red ONLY

QueueAction.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { AsyncAction } from './AsyncAction';
  2. /**
  3. * We need this JSDoc comment for affecting ESDoc.
  4. * @ignore
  5. * @extends {Ignored}
  6. */
  7. export class QueueAction extends AsyncAction {
  8. constructor(scheduler, work) {
  9. super(scheduler, work);
  10. this.scheduler = scheduler;
  11. this.work = work;
  12. }
  13. schedule(state, delay = 0) {
  14. if (delay > 0) {
  15. return super.schedule(state, delay);
  16. }
  17. this.delay = delay;
  18. this.state = state;
  19. this.scheduler.flush(this);
  20. return this;
  21. }
  22. execute(state, delay) {
  23. return (delay > 0 || this.closed) ?
  24. super.execute(state, delay) :
  25. this._execute(state, delay);
  26. }
  27. requestAsyncId(scheduler, id, delay = 0) {
  28. // If delay exists and is greater than 0, or if the delay is null (the
  29. // action wasn't rescheduled) but was originally scheduled as an async
  30. // action, then recycle as an async action.
  31. if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
  32. return super.requestAsyncId(scheduler, id, delay);
  33. }
  34. // Otherwise flush the scheduler starting with this action.
  35. return scheduler.flush(this);
  36. }
  37. }
  38. //# sourceMappingURL=QueueAction.js.map