a zip code crypto-currency system good for red ONLY

queue.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { QueueAction } from './QueueAction';
  2. import { QueueScheduler } from './QueueScheduler';
  3. /**
  4. *
  5. * Queue Scheduler
  6. *
  7. * <span class="informal">Put every next task on a queue, instead of executing it immediately</span>
  8. *
  9. * `queue` scheduler, when used with delay, behaves the same as {@link async} scheduler.
  10. *
  11. * When used without delay, it schedules given task synchronously - executes it right when
  12. * it is scheduled. However when called recursively, that is when inside the scheduled task,
  13. * another task is scheduled with queue scheduler, instead of executing immediately as well,
  14. * that task will be put on a queue and wait for current one to finish.
  15. *
  16. * This means that when you execute task with `queue` scheduler, you are sure it will end
  17. * before any other task scheduled with that scheduler will start.
  18. *
  19. * @examples <caption>Schedule recursively first, then do something</caption>
  20. *
  21. * Rx.Scheduler.queue.schedule(() => {
  22. * Rx.Scheduler.queue.schedule(() => console.log('second')); // will not happen now, but will be put on a queue
  23. *
  24. * console.log('first');
  25. * });
  26. *
  27. * // Logs:
  28. * // "first"
  29. * // "second"
  30. *
  31. *
  32. * @example <caption>Reschedule itself recursively</caption>
  33. *
  34. * Rx.Scheduler.queue.schedule(function(state) {
  35. * if (state !== 0) {
  36. * console.log('before', state);
  37. * this.schedule(state - 1); // `this` references currently executing Action,
  38. * // which we reschedule with new state
  39. * console.log('after', state);
  40. * }
  41. * }, 0, 3);
  42. *
  43. * // In scheduler that runs recursively, you would expect:
  44. * // "before", 3
  45. * // "before", 2
  46. * // "before", 1
  47. * // "after", 1
  48. * // "after", 2
  49. * // "after", 3
  50. *
  51. * // But with queue it logs:
  52. * // "before", 3
  53. * // "after", 3
  54. * // "before", 2
  55. * // "after", 2
  56. * // "before", 1
  57. * // "after", 1
  58. *
  59. *
  60. * @static true
  61. * @name queue
  62. * @owner Scheduler
  63. */
  64. export const queue = new QueueScheduler(QueueAction);
  65. //# sourceMappingURL=queue.js.map