/// /// /// module Rx { export interface VirtualTimeScheduler extends IScheduler { /** * Adds a relative time value to an absolute time value. * @param {Number} absolute Absolute virtual time value. * @param {Number} relative Relative virtual time value to add. * @return {Number} Resulting absolute virtual time sum value. */ add(from: TAbsolute, by: TRelative): TAbsolute; /** * Converts an absolute time to a number * @param {Any} The absolute time. * @returns {Number} The absolute time in ms */ toAbsoluteTime(duetime: TAbsolute): number; /** * Converts the TimeSpan value to a relative virtual time value. * @param {Number} timeSpan TimeSpan value to convert. * @return {Number} Corresponding relative virtual time value. */ toRelativeTime(duetime: number): TRelative; /** * Starts the virtual time scheduler. */ start(): IDisposable; /** * Stops the virtual time scheduler. */ stop(): void; /** * Advances the scheduler's clock to the specified time, running all work till that point. * @param {Number} time Absolute time to advance the scheduler's clock to. */ advanceTo(time: TAbsolute): void; /** * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan. * @param {Number} time Relative time to advance the scheduler's clock by. */ advanceBy(time: TRelative): void; /** * Advances the scheduler's clock by the specified relative time. * @param {Number} time Relative time to advance the scheduler's clock by. */ sleep(time: TRelative): void; isEnabled: boolean; /** * Gets the next scheduled item to be executed. * @returns {ScheduledItem} The next scheduled item. */ getNext(): internals.ScheduledItem; /** * Schedules an action to be executed after dueTime. * @param {Mixed} state State passed to the action to be executed. * @param {Number} dueTime Relative time after which to execute the action. * @param {Function} action Action to be executed. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). */ scheduleRelative(state: any, dueTime: TRelative, action: (scheduler: IScheduler, state: any) => IDisposable):IDisposable; /** * Schedules an action to be executed at dueTime. * @param {Mixed} state State passed to the action to be executed. * @param {Number} dueTime Absolute time at which to execute the action. * @param {Function} action Action to be executed. * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). */ scheduleAbsolute(state: any, dueTime: TAbsolute, action: (scheduler: IScheduler, state: any) => IDisposable):IDisposable; } } (function() { interface TA { } interface TR { } var vts: Rx.VirtualTimeScheduler; var b: boolean = vts.isEnabled; var a: TA = vts.add(100, 500); var n: number = vts.toAbsoluteTime(1000); var r: TR = vts.toRelativeTime(1000); var d: Rx.IDisposable = vts.start(); vts.stop(); vts.advanceTo(null); vts.advanceBy(null); vts.sleep(null); var i: Rx.internals.ScheduledItem = vts.getNext(); b = vts.isEnabled; })