aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/src/internal/scheduler/queue.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-28 17:26:46 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-28 17:43:56 -0700
commite4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 (patch)
tree06284a538a6008eca75051399e47db4e5d50301c /node_modules/rxjs/src/internal/scheduler/queue.ts
initial commit: scaffolding
Diffstat (limited to 'node_modules/rxjs/src/internal/scheduler/queue.ts')
-rw-r--r--node_modules/rxjs/src/internal/scheduler/queue.ts72
1 files changed, 72 insertions, 0 deletions
diff --git a/node_modules/rxjs/src/internal/scheduler/queue.ts b/node_modules/rxjs/src/internal/scheduler/queue.ts
new file mode 100644
index 0000000..df4e216
--- /dev/null
+++ b/node_modules/rxjs/src/internal/scheduler/queue.ts
@@ -0,0 +1,72 @@
+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 asyncScheduler} 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
+ * Schedule recursively first, then do something
+ * ```ts
+ * import { queueScheduler } from 'rxjs';
+ *
+ * queueScheduler.schedule(() => {
+ * queueScheduler.schedule(() => console.log('second')); // will not happen now, but will be put on a queue
+ *
+ * console.log('first');
+ * });
+ *
+ * // Logs:
+ * // "first"
+ * // "second"
+ * ```
+ *
+ * Reschedule itself recursively
+ * ```ts
+ * import { queueScheduler } from 'rxjs';
+ *
+ * queueScheduler.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
+ * ```
+ */
+
+export const queueScheduler = new QueueScheduler(QueueAction);
+
+/**
+ * @deprecated Renamed to {@link queueScheduler}. Will be removed in v8.
+ */
+export const queue = queueScheduler;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage