95b769e581f035f627a7593a08a8def14756eb855aafba93a5b2b87a50dcbacc58574dd480da0d820871b57134fedefc527e517e3afcfd0290ab5fa225d684 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { SchedulerLike, OperatorFunction } from '../types';
  2. /**
  3. * Emits an object containing the current value, and the time that has
  4. * passed between emitting the current value and the previous value, which is
  5. * calculated by using the provided `scheduler`'s `now()` method to retrieve
  6. * the current time at each emission, then calculating the difference. The `scheduler`
  7. * defaults to {@link asyncScheduler}, so by default, the `interval` will be in
  8. * milliseconds.
  9. *
  10. * <span class="informal">Convert an Observable that emits items into one that
  11. * emits indications of the amount of time elapsed between those emissions.</span>
  12. *
  13. * ![](timeInterval.png)
  14. *
  15. * ## Example
  16. *
  17. * Emit interval between current value with the last value
  18. *
  19. * ```ts
  20. * import { interval, timeInterval } from 'rxjs';
  21. *
  22. * const seconds = interval(1000);
  23. *
  24. * seconds
  25. * .pipe(timeInterval())
  26. * .subscribe(value => console.log(value));
  27. *
  28. * // NOTE: The values will never be this precise,
  29. * // intervals created with `interval` or `setInterval`
  30. * // are non-deterministic.
  31. *
  32. * // { value: 0, interval: 1000 }
  33. * // { value: 1, interval: 1000 }
  34. * // { value: 2, interval: 1000 }
  35. * ```
  36. *
  37. * @param scheduler Scheduler used to get the current time.
  38. * @return A function that returns an Observable that emits information about
  39. * value and interval.
  40. */
  41. export declare function timeInterval<T>(scheduler?: SchedulerLike): OperatorFunction<T, TimeInterval<T>>;
  42. export declare class TimeInterval<T> {
  43. value: T;
  44. interval: number;
  45. /**
  46. * @deprecated Internal implementation detail, do not construct directly. Will be made an interface in v8.
  47. */
  48. constructor(value: T, interval: number);
  49. }
  50. //# sourceMappingURL=timeInterval.d.ts.map