1 import { QueueAction } from './QueueAction';
2 import { QueueScheduler } from './QueueScheduler';
8 * <span class="informal">Put every next task on a queue, instead of executing it immediately</span>
10 * `queue` scheduler, when used with delay, behaves the same as {@link asyncScheduler} scheduler.
12 * When used without delay, it schedules given task synchronously - executes it right when
13 * it is scheduled. However when called recursively, that is when inside the scheduled task,
14 * another task is scheduled with queue scheduler, instead of executing immediately as well,
15 * that task will be put on a queue and wait for current one to finish.
17 * This means that when you execute task with `queue` scheduler, you are sure it will end
18 * before any other task scheduled with that scheduler will start.
21 * Schedule recursively first, then do something
23 * import { queueScheduler } from 'rxjs';
25 * queueScheduler.schedule(() => {
26 * queueScheduler.schedule(() => console.log('second')); // will not happen now, but will be put on a queue
28 * console.log('first');
36 * Reschedule itself recursively
38 * import { queueScheduler } from 'rxjs';
40 * queueScheduler.schedule(function(state) {
42 * console.log('before', state);
43 * this.schedule(state - 1); // `this` references currently executing Action,
44 * // which we reschedule with new state
45 * console.log('after', state);
49 * // In scheduler that runs recursively, you would expect:
57 * // But with queue it logs:
66 export const queueScheduler = new QueueScheduler(QueueAction);
69 * @deprecated renamed. Use {@link queueScheduler}
71 export const queue = queueScheduler;