Front end of the Slack clone application.

Scheduler.d.ts 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { Action } from './scheduler/Action';
  2. import { Subscription } from './Subscription';
  3. export interface IScheduler {
  4. now(): number;
  5. schedule<T>(work: (this: Action<T>, state?: T) => void, delay?: number, state?: T): Subscription;
  6. }
  7. /**
  8. * An execution context and a data structure to order tasks and schedule their
  9. * execution. Provides a notion of (potentially virtual) time, through the
  10. * `now()` getter method.
  11. *
  12. * Each unit of work in a Scheduler is called an {@link Action}.
  13. *
  14. * ```ts
  15. * class Scheduler {
  16. * now(): number;
  17. * schedule(work, delay?, state?): Subscription;
  18. * }
  19. * ```
  20. *
  21. * @class Scheduler
  22. */
  23. export declare class Scheduler implements IScheduler {
  24. private SchedulerAction;
  25. static now: () => number;
  26. constructor(SchedulerAction: typeof Action, now?: () => number);
  27. /**
  28. * A getter method that returns a number representing the current time
  29. * (at the time this function was called) according to the scheduler's own
  30. * internal clock.
  31. * @return {number} A number that represents the current time. May or may not
  32. * have a relation to wall-clock time. May or may not refer to a time unit
  33. * (e.g. milliseconds).
  34. */
  35. now: () => number;
  36. /**
  37. * Schedules a function, `work`, for execution. May happen at some point in
  38. * the future, according to the `delay` parameter, if specified. May be passed
  39. * some context object, `state`, which will be passed to the `work` function.
  40. *
  41. * The given arguments will be processed an stored as an Action object in a
  42. * queue of actions.
  43. *
  44. * @param {function(state: ?T): ?Subscription} work A function representing a
  45. * task, or some unit of work to be executed by the Scheduler.
  46. * @param {number} [delay] Time to wait before executing the work, where the
  47. * time unit is implicit and defined by the Scheduler itself.
  48. * @param {T} [state] Some contextual data that the `work` function uses when
  49. * called by the Scheduler.
  50. * @return {Subscription} A subscription in order to be able to unsubscribe
  51. * the scheduled work.
  52. */
  53. schedule<T>(work: (this: Action<T>, state?: T) => void, delay?: number, state?: T): Subscription;
  54. }