rx.virtualtime.d.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. declare module Rx {
  2. export interface VirtualTimeScheduler<TAbsolute, TRelative> extends IScheduler {
  3. /**
  4. * Adds a relative time value to an absolute time value.
  5. * @param {Number} absolute Absolute virtual time value.
  6. * @param {Number} relative Relative virtual time value to add.
  7. * @return {Number} Resulting absolute virtual time sum value.
  8. */
  9. add(from: TAbsolute, by: TRelative): TAbsolute;
  10. /**
  11. * Converts an absolute time to a number
  12. * @param {Any} The absolute time.
  13. * @returns {Number} The absolute time in ms
  14. */
  15. toAbsoluteTime(duetime: TAbsolute): number;
  16. /**
  17. * Converts the TimeSpan value to a relative virtual time value.
  18. * @param {Number} timeSpan TimeSpan value to convert.
  19. * @return {Number} Corresponding relative virtual time value.
  20. */
  21. toRelativeTime(duetime: number): TRelative;
  22. /**
  23. * Starts the virtual time scheduler.
  24. */
  25. start(): IDisposable;
  26. /**
  27. * Stops the virtual time scheduler.
  28. */
  29. stop(): void;
  30. /**
  31. * Advances the scheduler's clock to the specified time, running all work till that point.
  32. * @param {Number} time Absolute time to advance the scheduler's clock to.
  33. */
  34. advanceTo(time: TAbsolute): void;
  35. /**
  36. * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.
  37. * @param {Number} time Relative time to advance the scheduler's clock by.
  38. */
  39. advanceBy(time: TRelative): void;
  40. /**
  41. * Advances the scheduler's clock by the specified relative time.
  42. * @param {Number} time Relative time to advance the scheduler's clock by.
  43. */
  44. sleep(time: TRelative): void;
  45. isEnabled: boolean;
  46. /**
  47. * Gets the next scheduled item to be executed.
  48. * @returns {ScheduledItem} The next scheduled item.
  49. */
  50. getNext(): internals.ScheduledItem<TAbsolute>;
  51. }
  52. export interface HistoricalScheduler extends VirtualTimeScheduler<number, number> {
  53. }
  54. export var HistoricalScheduler: {
  55. /**
  56. * Creates a new historical scheduler with the specified initial clock value.
  57. * @constructor
  58. * @param {Number} initialClock Initial value for the clock.
  59. * @param {Function} comparer Comparer to determine causality of events based on absolute time.
  60. */
  61. new (initialClock: number, comparer: _Comparer<number, number>): HistoricalScheduler;
  62. };
  63. }
  64. declare module "rx.virtualtime" { export = Rx; }