aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/Action.ts36
-rw-r--r--sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts47
-rw-r--r--sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts31
-rw-r--r--sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AsapAction.ts48
-rw-r--r--sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/animationFrame.ts40
-rw-r--r--sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/asap.ts43
6 files changed, 245 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/Action.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/Action.ts
new file mode 100644
index 00000000..6cf91bcb
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/Action.ts
@@ -0,0 +1,36 @@
+import { Scheduler } from '../Scheduler';
+import { Subscription } from '../Subscription';
+import { SchedulerAction } from '../types';
+
+/**
+ * A unit of work to be executed in a `scheduler`. An action is typically
+ * created from within a {@link SchedulerLike} and an RxJS user does not need to concern
+ * themselves about creating and manipulating an Action.
+ *
+ * ```ts
+ * class Action<T> extends Subscription {
+ * new (scheduler: Scheduler, work: (state?: T) => void);
+ * schedule(state?: T, delay: number = 0): Subscription;
+ * }
+ * ```
+ *
+ * @class Action<T>
+ */
+export class Action<T> extends Subscription {
+ constructor(scheduler: Scheduler, work: (this: SchedulerAction<T>, state?: T) => void) {
+ super();
+ }
+ /**
+ * Schedules this action on its parent {@link SchedulerLike} for execution. May be passed
+ * some context object, `state`. May happen at some point in the future,
+ * according to the `delay` parameter, if specified.
+ * @param {T} [state] Some contextual data that the `work` function uses when
+ * called by the Scheduler.
+ * @param {number} [delay] Time to wait before executing the work, where the
+ * time unit is implicit and defined by the Scheduler.
+ * @return {void}
+ */
+ public schedule(state?: T, delay: number = 0): Subscription {
+ return this;
+ }
+}
diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts
new file mode 100644
index 00000000..e9ea64fa
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts
@@ -0,0 +1,47 @@
+import { AsyncAction } from './AsyncAction';
+import { AnimationFrameScheduler } from './AnimationFrameScheduler';
+import { SchedulerAction } from '../types';
+
+/**
+ * We need this JSDoc comment for affecting ESDoc.
+ * @ignore
+ * @extends {Ignored}
+ */
+export class AnimationFrameAction<T> extends AsyncAction<T> {
+
+ constructor(protected scheduler: AnimationFrameScheduler,
+ protected work: (this: SchedulerAction<T>, state?: T) => void) {
+ super(scheduler, work);
+ }
+
+ protected requestAsyncId(scheduler: AnimationFrameScheduler, id?: any, delay: number = 0): any {
+ // If delay is greater than 0, request as an async action.
+ if (delay !== null && delay > 0) {
+ return super.requestAsyncId(scheduler, id, delay);
+ }
+ // Push the action to the end of the scheduler queue.
+ scheduler.actions.push(this);
+ // If an animation frame has already been requested, don't request another
+ // one. If an animation frame hasn't been requested yet, request one. Return
+ // the current animation frame request id.
+ return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(
+ () => scheduler.flush(null)));
+ }
+ protected recycleAsyncId(scheduler: AnimationFrameScheduler, id?: any, delay: number = 0): any {
+ // If delay exists and is greater than 0, or if the delay is null (the
+ // action wasn't rescheduled) but was originally scheduled as an async
+ // action, then recycle as an async action.
+ if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
+ return super.recycleAsyncId(scheduler, id, delay);
+ }
+ // If the scheduler queue is empty, cancel the requested animation frame and
+ // set the scheduled flag to undefined so the next AnimationFrameAction will
+ // request its own.
+ if (scheduler.actions.length === 0) {
+ cancelAnimationFrame(id);
+ scheduler.scheduled = undefined;
+ }
+ // Return undefined so the action knows to request a new async id if it's rescheduled.
+ return undefined;
+ }
+}
diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts
new file mode 100644
index 00000000..c550429f
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts
@@ -0,0 +1,31 @@
+import { AsyncAction } from './AsyncAction';
+import { AsyncScheduler } from './AsyncScheduler';
+
+export class AnimationFrameScheduler extends AsyncScheduler {
+ public flush(action?: AsyncAction<any>): void {
+
+ this.active = true;
+ this.scheduled = undefined;
+
+ const {actions} = this;
+ let error: any;
+ let index: number = -1;
+ let count: number = actions.length;
+ action = action || actions.shift();
+
+ do {
+ if (error = action.execute(action.state, action.delay)) {
+ break;
+ }
+ } while (++index < count && (action = actions.shift()));
+
+ this.active = false;
+
+ if (error) {
+ while (++index < count && (action = actions.shift())) {
+ action.unsubscribe();
+ }
+ throw error;
+ }
+ }
+}
diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AsapAction.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AsapAction.ts
new file mode 100644
index 00000000..1fe1622d
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AsapAction.ts
@@ -0,0 +1,48 @@
+import { Immediate } from '../util/Immediate';
+import { AsyncAction } from './AsyncAction';
+import { AsapScheduler } from './AsapScheduler';
+import { SchedulerAction } from '../types';
+/**
+ * We need this JSDoc comment for affecting ESDoc.
+ * @ignore
+ * @extends {Ignored}
+ */
+export class AsapAction<T> extends AsyncAction<T> {
+
+ constructor(protected scheduler: AsapScheduler,
+ protected work: (this: SchedulerAction<T>, state?: T) => void) {
+ super(scheduler, work);
+ }
+
+ protected requestAsyncId(scheduler: AsapScheduler, id?: any, delay: number = 0): any {
+ // If delay is greater than 0, request as an async action.
+ if (delay !== null && delay > 0) {
+ return super.requestAsyncId(scheduler, id, delay);
+ }
+ // Push the action to the end of the scheduler queue.
+ scheduler.actions.push(this);
+ // If a microtask has already been scheduled, don't schedule another
+ // one. If a microtask hasn't been scheduled yet, schedule one now. Return
+ // the current scheduled microtask id.
+ return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(
+ scheduler.flush.bind(scheduler, null)
+ ));
+ }
+ protected recycleAsyncId(scheduler: AsapScheduler, id?: any, delay: number = 0): any {
+ // If delay exists and is greater than 0, or if the delay is null (the
+ // action wasn't rescheduled) but was originally scheduled as an async
+ // action, then recycle as an async action.
+ if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
+ return super.recycleAsyncId(scheduler, id, delay);
+ }
+ // If the scheduler queue is empty, cancel the requested microtask and
+ // set the scheduled flag to undefined so the next AsapAction will schedule
+ // its own.
+ if (scheduler.actions.length === 0) {
+ Immediate.clearImmediate(id);
+ scheduler.scheduled = undefined;
+ }
+ // Return undefined so the action knows to request a new async id if it's rescheduled.
+ return undefined;
+ }
+}
diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/animationFrame.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/animationFrame.ts
new file mode 100644
index 00000000..a3f62050
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/animationFrame.ts
@@ -0,0 +1,40 @@
+import { AnimationFrameAction } from './AnimationFrameAction';
+import { AnimationFrameScheduler } from './AnimationFrameScheduler';
+
+/**
+ *
+ * Animation Frame Scheduler
+ *
+ * <span class="informal">Perform task when `window.requestAnimationFrame` would fire</span>
+ *
+ * When `animationFrame` scheduler is used with delay, it will fall back to {@link asyncScheduler} scheduler
+ * behaviour.
+ *
+ * Without delay, `animationFrame` scheduler can be used to create smooth browser animations.
+ * It makes sure scheduled task will happen just before next browser content repaint,
+ * thus performing animations as efficiently as possible.
+ *
+ * ## Example
+ * Schedule div height animation
+ * ```ts
+ * // html: <div style="background: #0ff;"></div>
+ * import { animationFrameScheduler } from 'rxjs';
+ *
+ * const div = document.querySelector('div');
+ *
+ * animationFrameScheduler.schedule(function(height) {
+ * div.style.height = height + "px";
+ *
+ * this.schedule(height + 1); // `this` references currently executing Action,
+ * // which we reschedule with new state
+ * }, 0, 0);
+ *
+ * // You will see a div element growing in height
+ * ```
+ */
+export const animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);
+
+/**
+ * @deprecated renamed. Use {@link animationFrameScheduler}
+ */
+export const animationFrame = animationFrameScheduler;
diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/asap.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/asap.ts
new file mode 100644
index 00000000..bbd721d2
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/asap.ts
@@ -0,0 +1,43 @@
+import { AsapAction } from './AsapAction';
+import { AsapScheduler } from './AsapScheduler';
+
+/**
+ *
+ * Asap Scheduler
+ *
+ * <span class="informal">Perform task as fast as it can be performed asynchronously</span>
+ *
+ * `asap` scheduler behaves the same as {@link asyncScheduler} scheduler when you use it to delay task
+ * in time. If however you set delay to `0`, `asap` will wait for current synchronously executing
+ * code to end and then it will try to execute given task as fast as possible.
+ *
+ * `asap` scheduler will do its best to minimize time between end of currently executing code
+ * and start of scheduled task. This makes it best candidate for performing so called "deferring".
+ * Traditionally this was achieved by calling `setTimeout(deferredTask, 0)`, but that technique involves
+ * some (although minimal) unwanted delay.
+ *
+ * Note that using `asap` scheduler does not necessarily mean that your task will be first to process
+ * after currently executing code. In particular, if some task was also scheduled with `asap` before,
+ * that task will execute first. That being said, if you need to schedule task asynchronously, but
+ * as soon as possible, `asap` scheduler is your best bet.
+ *
+ * ## Example
+ * Compare async and asap scheduler<
+ * ```ts
+ * import { asapScheduler, asyncScheduler } from 'rxjs';
+ *
+ * asyncScheduler.schedule(() => console.log('async')); // scheduling 'async' first...
+ * asapScheduler.schedule(() => console.log('asap'));
+ *
+ * // Logs:
+ * // "asap"
+ * // "async"
+ * // ... but 'asap' goes first!
+ * ```
+ */
+export const asapScheduler = new AsapScheduler(AsapAction);
+
+/**
+ * @deprecated renamed. Use {@link asapScheduler}
+ */
+export const asap = asapScheduler;