Debian Codegraph @

node/rxjs/src/internal/scheduler/Action.ts

raw
1 import { Scheduler } from '../Scheduler';
2 import { Subscription } from '../Subscription';
3 import { SchedulerAction } from '../types';
4
5 /**
6 * A unit of work to be executed in a `scheduler`. An action is typically
7 * created from within a {@link SchedulerLike} and an RxJS user does not need to concern
8 * themselves about creating and manipulating an Action.
9 *
10 * ```ts
11 * class Action<T> extends Subscription {
12 * new (scheduler: Scheduler, work: (state?: T) => void);
13 * schedule(state?: T, delay: number = 0): Subscription;
14 * }
15 * ```
16 */
17 export class Action<T> extends Subscription {
18 constructor(scheduler: Scheduler, work: (this: SchedulerAction<T>, state?: T) => void) {
19 super();
20 }
21 /**
22 * Schedules this action on its parent {@link SchedulerLike} for execution. May be passed
23 * some context object, `state`. May happen at some point in the future,
24 * according to the `delay` parameter, if specified.
25 * @param state Some contextual data that the `work` function uses when called by the
26 * Scheduler.
27 * @param delay Time to wait before executing the work, where the time unit is implicit
28 * and defined by the Scheduler.
29 * @return A subscription in order to be able to unsubscribe the scheduled work.
30 */
31 public schedule(state?: T, delay: number = 0): Subscription {
32 return this;
33 }
34 }