Sha256: eeb31d713759373cb3f5564b02538ee8a4a10263934d35b4a88a9bbf9416df75

Contents?: true

Size: 1.91 KB

Versions: 49

Compression:

Stored size: 1.91 KB

Contents

import { QueueAction } from './QueueAction';
import { QueueScheduler } from './QueueScheduler';

/**
 *
 * Queue Scheduler
 *
 * <span class="informal">Put every next task on a queue, instead of executing it immediately</span>
 *
 * `queue` scheduler, when used with delay, behaves the same as {@link async} scheduler.
 *
 * When used without delay, it schedules given task synchronously - executes it right when
 * it is scheduled. However when called recursively, that is when inside the scheduled task,
 * another task is scheduled with queue scheduler, instead of executing immediately as well,
 * that task will be put on a queue and wait for current one to finish.
 *
 * This means that when you execute task with `queue` scheduler, you are sure it will end
 * before any other task scheduled with that scheduler will start.
 *
 * @examples <caption>Schedule recursively first, then do something</caption>
 *
 * Rx.Scheduler.queue.schedule(() => {
 *   Rx.Scheduler.queue.schedule(() => console.log('second')); // will not happen now, but will be put on a queue
 *
 *   console.log('first');
 * });
 *
 * // Logs:
 * // "first"
 * // "second"
 *
 *
 * @example <caption>Reschedule itself recursively</caption>
 *
 * Rx.Scheduler.queue.schedule(function(state) {
 *   if (state !== 0) {
 *     console.log('before', state);
 *     this.schedule(state - 1); // `this` references currently executing Action,
 *                               // which we reschedule with new state
 *     console.log('after', state);
 *   }
 * }, 0, 3);
 *
 * // In scheduler that runs recursively, you would expect:
 * // "before", 3
 * // "before", 2
 * // "before", 1
 * // "after", 1
 * // "after", 2
 * // "after", 3
 *
 * // But with queue it logs:
 * // "before", 3
 * // "after", 3
 * // "before", 2
 * // "after", 2
 * // "before", 1
 * // "after", 1
 *
 *
 * @static true
 * @name queue
 * @owner Scheduler
 */

export const queue = new QueueScheduler(QueueAction);

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
govuk_publishing_components-17.8.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.7.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.6.1 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.6.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.5.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.4.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.3.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.2.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.1.1 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.1.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-17.0.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.29.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.28.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.27.1 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.27.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.26.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.25.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.24.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.23.0 node_modules/rxjs/src/scheduler/queue.ts
govuk_publishing_components-16.22.0 node_modules/rxjs/src/scheduler/queue.ts