rx.time.d.ts 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. declare module Rx {
  2. export interface ObservableStatic {
  3. /**
  4. * Returns an observable sequence that produces a value after each period.
  5. *
  6. * @example
  7. * 1 - res = Rx.Observable.interval(1000);
  8. * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);
  9. *
  10. * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).
  11. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.
  12. * @returns {Observable} An observable sequence that produces a value after each period.
  13. */
  14. interval(period: number, scheduler?: IScheduler): Observable<number>;
  15. }
  16. export interface ObservableStatic {
  17. /**
  18. * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.
  19. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.
  20. * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.
  21. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.
  22. * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.
  23. */
  24. timer(dueTime: number, period: number, scheduler?: IScheduler): Observable<number>;
  25. /**
  26. * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.
  27. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.
  28. * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.
  29. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.
  30. * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.
  31. */
  32. timer(dueTime: number, scheduler?: IScheduler): Observable<number>;
  33. }
  34. export interface Observable<T> {
  35. /**
  36. * Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.
  37. *
  38. * @example
  39. * 1 - res = Rx.Observable.delay(new Date());
  40. * 2 - res = Rx.Observable.delay(new Date(), Rx.Scheduler.timeout);
  41. *
  42. * 3 - res = Rx.Observable.delay(5000);
  43. * 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout);
  44. * @memberOf Observable#
  45. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.
  46. * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.
  47. * @returns {Observable} Time-shifted sequence.
  48. */
  49. delay(dueTime: Date, scheduler?: IScheduler): Observable<T>;
  50. /**
  51. * Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.
  52. *
  53. * @example
  54. * 1 - res = Rx.Observable.delay(new Date());
  55. * 2 - res = Rx.Observable.delay(new Date(), Rx.Scheduler.timeout);
  56. *
  57. * 3 - res = Rx.Observable.delay(5000);
  58. * 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout);
  59. * @memberOf Observable#
  60. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.
  61. * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.
  62. * @returns {Observable} Time-shifted sequence.
  63. */
  64. delay(dueTime: number, scheduler?: IScheduler): Observable<T>;
  65. /**
  66. * Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  67. *
  68. * @example
  69. * 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only
  70. * 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector
  71. *
  72. * @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.
  73. * @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.
  74. * @returns {Observable} Time-shifted sequence.
  75. */
  76. delay(delayDurationSelector: (item: T) => ObservableOrPromise<number>): Observable<T>;
  77. /**
  78. * Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  79. *
  80. * @example
  81. * 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only
  82. * 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector
  83. *
  84. * @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.
  85. * @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.
  86. * @returns {Observable} Time-shifted sequence.
  87. */
  88. delay(subscriptionDelay: Observable<number>, delayDurationSelector: (item: T) => ObservableOrPromise<number>): Observable<T>;
  89. }
  90. export interface Observable<T> {
  91. /**
  92. * Ignores values from an observable sequence which are followed by another value before dueTime.
  93. * @param {Number} dueTime Duration of the debounce period for each value (specified as an integer denoting milliseconds).
  94. * @param {Scheduler} [scheduler] Scheduler to run the debounce timers on. If not specified, the timeout scheduler is used.
  95. * @returns {Observable} The debounced sequence.
  96. */
  97. debounce(dueTime: number, scheduler?: IScheduler): Observable<T>;
  98. /**
  99. * Ignores values from an observable sequence which are followed by another value within a computed throttle duration.
  100. * @param {Function} durationSelector Selector function to retrieve a sequence indicating the throttle duration for each given element.
  101. * @returns {Observable} The debounced sequence.
  102. */
  103. debounce(debounceDurationSelector: (item: T) => ObservableOrPromise<any>): Observable<T>;
  104. }
  105. export interface Observable<T> {
  106. /**
  107. * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  108. * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).
  109. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.
  110. * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.
  111. * @returns {Observable} An observable sequence of windows.
  112. */
  113. windowWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable<Observable<T>>;
  114. /**
  115. * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  116. * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).
  117. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.
  118. * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.
  119. * @returns {Observable} An observable sequence of windows.
  120. */
  121. windowWithTime(timeSpan: number, scheduler?: IScheduler): Observable<Observable<T>>;
  122. }
  123. export interface Observable<T> {
  124. /**
  125. * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.
  126. * @param {Number} timeSpan Maximum time length of a window.
  127. * @param {Number} count Maximum element count of a window.
  128. * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.
  129. * @returns {Observable} An observable sequence of windows.
  130. */
  131. windowWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable<Observable<T>>;
  132. }
  133. export interface Observable<T> {
  134. /**
  135. * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  136. * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).
  137. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.
  138. * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.
  139. * @returns {Observable} An observable sequence of buffers.
  140. */
  141. bufferWithTime(timeSpan: number, timeShift: number, scheduler?: IScheduler): Observable<T[]>;
  142. /**
  143. * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  144. * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).
  145. * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.
  146. * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.
  147. * @returns {Observable} An observable sequence of buffers.
  148. */
  149. bufferWithTime(timeSpan: number, scheduler?: IScheduler): Observable<T[]>;
  150. }
  151. export interface Observable<T> {
  152. /**
  153. * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed.
  154. * @param {Number} timeSpan Maximum time length of a buffer.
  155. * @param {Number} count Maximum element count of a buffer.
  156. * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used.
  157. * @returns {Observable} An observable sequence of buffers.
  158. */
  159. bufferWithTimeOrCount(timeSpan: number, count: number, scheduler?: IScheduler): Observable<T[]>;
  160. }
  161. export interface TimeInterval<T> {
  162. value: T;
  163. interval: number;
  164. }
  165. export interface Observable<T> {
  166. /**
  167. * Records the time interval between consecutive values in an observable sequence.
  168. *
  169. * @example
  170. * 1 - res = source.timeInterval();
  171. * 2 - res = source.timeInterval(Rx.Scheduler.timeout);
  172. *
  173. * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used.
  174. * @returns {Observable} An observable sequence with time interval information on values.
  175. */
  176. timeInterval(scheduler?: IScheduler): Observable<TimeInterval<T>>;
  177. }
  178. export interface Timestamp<T> {
  179. value: T;
  180. timestamp: number;
  181. }
  182. export interface Observable<T> {
  183. /**
  184. * Records the timestamp for each value in an observable sequence.
  185. *
  186. * @example
  187. * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }
  188. * 2 - res = source.timestamp(Rx.Scheduler.default);
  189. *
  190. * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.
  191. * @returns {Observable} An observable sequence with timestamp information on values.
  192. */
  193. timestamp(scheduler?: IScheduler): Observable<Timestamp<T>>;
  194. }
  195. export interface Observable<T> {
  196. /**
  197. * Samples the observable sequence at each interval.
  198. *
  199. * @example
  200. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  201. * 2 - res = source.sample(5000); // 5 seconds
  202. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  203. *
  204. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  205. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  206. * @returns {Observable} Sampled observable sequence.
  207. */
  208. sample(intervalOrSampler: number, scheduler?: IScheduler): Observable<T>;
  209. /**
  210. * Samples the observable sequence at each interval.
  211. *
  212. * @example
  213. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  214. * 2 - res = source.sample(5000); // 5 seconds
  215. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  216. *
  217. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  218. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  219. * @returns {Observable} Sampled observable sequence.
  220. */
  221. sample<TSample>(sampler: Observable<TSample>, scheduler?: IScheduler): Observable<T>;
  222. /**
  223. * Samples the observable sequence at each interval.
  224. *
  225. * @example
  226. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  227. * 2 - res = source.sample(5000); // 5 seconds
  228. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  229. *
  230. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  231. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  232. * @returns {Observable} Sampled observable sequence.
  233. */
  234. throttleLatest(interval: number, scheduler?: IScheduler): Observable<T>;
  235. /**
  236. * Samples the observable sequence at each interval.
  237. *
  238. * @example
  239. * 1 - res = source.sample(sampleObservable); // Sampler tick sequence
  240. * 2 - res = source.sample(5000); // 5 seconds
  241. * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds
  242. *
  243. * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.
  244. * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.
  245. * @returns {Observable} Sampled observable sequence.
  246. */
  247. throttleLatest<TSample>(sampler: Observable<TSample>, scheduler?: IScheduler): Observable<T>;
  248. }
  249. export interface Observable<T> {
  250. /**
  251. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  252. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  253. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  254. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  255. */
  256. timeout(dueTime: Date, scheduler?: IScheduler): Observable<T>;
  257. /**
  258. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  259. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  260. * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
  261. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  262. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  263. */
  264. timeout(dueTime: Date, other?: Observable<T>, scheduler?: IScheduler): Observable<T>;
  265. /**
  266. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  267. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  268. * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
  269. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  270. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  271. */
  272. timeout(dueTime: number, scheduler?: IScheduler): Observable<T>;
  273. /**
  274. * Returns the source observable sequence or the other observable sequence if dueTime elapses.
  275. * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.
  276. * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.
  277. * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.
  278. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  279. */
  280. timeout(dueTime: number, other?: Observable<T>, scheduler?: IScheduler): Observable<T>;
  281. /**
  282. * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
  283. * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.
  284. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  285. */
  286. timeout<TTimeout>(timeoutdurationSelector: (item: T) => Observable<TTimeout>): Observable<T>;
  287. /**
  288. * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
  289. * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.
  290. * @param {Observable} other Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException().
  291. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  292. */
  293. timeout<TTimeout>(timeoutdurationSelector: (item: T) => Observable<TTimeout>, other: Observable<T>): Observable<T>;
  294. /**
  295. * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.
  296. * @param {Observable} [firstTimeout] Observable sequence that represents the timeout for the first element. If not provided, this defaults to Observable.never().
  297. * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.
  298. * @param {Observable} [other] Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException().
  299. * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.
  300. */
  301. timeout<TTimeout>(firstTimeout: Observable<TTimeout>, timeoutdurationSelector: (item: T) => Observable<TTimeout>, other?: Observable<T>): Observable<T>;
  302. }
  303. export interface ObservableStatic {
  304. /**
  305. * Generates an observable sequence by iterating a state from an initial state until the condition fails.
  306. *
  307. * @example
  308. * res = source.generateWithAbsoluteTime(0,
  309. * function (x) { return return true; },
  310. * function (x) { return x + 1; },
  311. * function (x) { return x; },
  312. * function (x) { return new Date(); }
  313. * });
  314. *
  315. * @param {Mixed} initialState Initial state.
  316. * @param {Function} condition Condition to terminate generation (upon returning false).
  317. * @param {Function} iterate Iteration step function.
  318. * @param {Function} resultSelector Selector function for results produced in the sequence.
  319. * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values.
  320. * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.
  321. * @returns {Observable} The generated sequence.
  322. */
  323. generateWithAbsoluteTime<TState, TResult>(
  324. initialState: TState,
  325. condition: (state: TState) => boolean,
  326. iterate: (state: TState) => TState,
  327. resultSelector: (state: TState) => TResult,
  328. timeSelector: (state: TState) => Date,
  329. scheduler?: IScheduler): Observable<TResult>;
  330. }
  331. export interface ObservableStatic {
  332. /**
  333. * Generates an observable sequence by iterating a state from an initial state until the condition fails.
  334. *
  335. * @example
  336. * res = source.generateWithRelativeTime(0,
  337. * function (x) { return return true; },
  338. * function (x) { return x + 1; },
  339. * function (x) { return x; },
  340. * function (x) { return 500; }
  341. * );
  342. *
  343. * @param {Mixed} initialState Initial state.
  344. * @param {Function} condition Condition to terminate generation (upon returning false).
  345. * @param {Function} iterate Iteration step function.
  346. * @param {Function} resultSelector Selector function for results produced in the sequence.
  347. * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds.
  348. * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.
  349. * @returns {Observable} The generated sequence.
  350. */
  351. generateWithRelativeTime<TState, TResult>(
  352. initialState: TState,
  353. condition: (state: TState) => boolean,
  354. iterate: (state: TState) => TState,
  355. resultSelector: (state: TState) => TResult,
  356. timeSelector: (state: TState) => number,
  357. scheduler?: IScheduler): Observable<TResult>;
  358. }
  359. export interface Observable<T> {
  360. /**
  361. * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
  362. *
  363. * @example
  364. * 1 - res = source.delaySubscription(5000); // 5s
  365. * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds
  366. *
  367. * @param {Number} dueTime Relative or absolute time shift of the subscription.
  368. * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.
  369. * @returns {Observable} Time-shifted sequence.
  370. */
  371. delaySubscription(dueTime: number, scheduler?: IScheduler): Observable<T>;
  372. }
  373. export interface Observable<T> {
  374. /**
  375. * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  376. *
  377. * 1 - res = source.skipLastWithTime(5000);
  378. * 2 - res = source.skipLastWithTime(5000, scheduler);
  379. *
  380. * @description
  381. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  382. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  383. * result sequence. This causes elements to be delayed with duration.
  384. * @param {Number} duration Duration for skipping elements from the end of the sequence.
  385. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout
  386. * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence.
  387. */
  388. skipLastWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  389. }
  390. export interface Observable<T> {
  391. /**
  392. * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.
  393. * @description
  394. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  395. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  396. * result sequence. This causes elements to be delayed with duration.
  397. * @param {Number} duration Duration for taking elements from the end of the sequence.
  398. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  399. * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence.
  400. */
  401. takeLastWithTime(duration: number, timerScheduler?: IScheduler, loopScheduler?: IScheduler): Observable<T>;
  402. }
  403. export interface Observable<T> {
  404. /**
  405. * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  406. * @description
  407. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  408. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  409. * result sequence. This causes elements to be delayed with duration.
  410. * @param {Number} duration Duration for taking elements from the end of the sequence.
  411. * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  412. * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence.
  413. */
  414. takeLastBufferWithTime(duration: number, scheduler?: IScheduler): Observable<T[]>;
  415. }
  416. export interface Observable<T> {
  417. /**
  418. * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  419. *
  420. * @example
  421. * 1 - res = source.takeWithTime(5000, [optional scheduler]);
  422. * @description
  423. * This operator accumulates a queue with a length enough to store elements received during the initial duration window.
  424. * As more elements are received, elements older than the specified duration are taken from the queue and produced on the
  425. * result sequence. This causes elements to be delayed with duration.
  426. * @param {Number} duration Duration for taking elements from the start of the sequence.
  427. * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  428. * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.
  429. */
  430. takeWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  431. }
  432. export interface Observable<T> {
  433. /**
  434. * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  435. *
  436. * @example
  437. * 1 - res = source.skipWithTime(5000, [optional scheduler]);
  438. *
  439. * @description
  440. * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence.
  441. * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded
  442. * may not execute immediately, despite the zero due time.
  443. *
  444. * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration.
  445. * @param {Number} duration Duration for skipping elements from the start of the sequence.
  446. * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  447. * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence.
  448. */
  449. skipWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  450. }
  451. export interface Observable<T> {
  452. /**
  453. * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  454. * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
  455. *
  456. * @examples
  457. * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);
  458. * 2 - res = source.skipUntilWithTime(5000, [scheduler]);
  459. * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
  460. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  461. * @returns {Observable} An observable sequence with the elements skipped until the specified start time.
  462. */
  463. skipUntilWithTime(startTime: Date, scheduler?: IScheduler): Observable<T>;
  464. /**
  465. * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  466. * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.
  467. *
  468. * @examples
  469. * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);
  470. * 2 - res = source.skipUntilWithTime(5000, [scheduler]);
  471. * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.
  472. * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.
  473. * @returns {Observable} An observable sequence with the elements skipped until the specified start time.
  474. */
  475. skipUntilWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  476. }
  477. export interface Observable<T> {
  478. /**
  479. * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  480. * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.
  481. * @param {Scheduler} [scheduler] Scheduler to run the timer on.
  482. * @returns {Observable} An observable sequence with the elements taken until the specified end time.
  483. */
  484. takeUntilWithTime(endTime: Date, scheduler?: IScheduler): Observable<T>;
  485. /**
  486. * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  487. * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.
  488. * @param {Scheduler} [scheduler] Scheduler to run the timer on.
  489. * @returns {Observable} An observable sequence with the elements taken until the specified end time.
  490. */
  491. takeUntilWithTime(duration: number, scheduler?: IScheduler): Observable<T>;
  492. }
  493. export interface Observable<T> {
  494. /**
  495. * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.
  496. * @param {Number} windowDuration time to wait before emitting another item after emitting the last item
  497. * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.
  498. * @returns {Observable} An Observable that performs the throttle operation.
  499. */
  500. throttle(windowDuration: number, scheduler?: IScheduler): Observable<T>;
  501. }
  502. }
  503. declare module "rx.time" { export = Rx; }