c6933179c904cf9191ccb52c68fd1e066b1bdf207ff6846d05b948fd7b7a68c062eecad6c2d16569f44274175584584e9f2a692a70ad2c0714240103df7771 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
  2. /**
  3. * Emits the most recently emitted value from the source Observable within
  4. * periodic time intervals.
  5. *
  6. * <span class="informal">Samples the source Observable at periodic time
  7. * intervals, emitting what it samples.</span>
  8. *
  9. * ![](sampleTime.png)
  10. *
  11. * `sampleTime` periodically looks at the source Observable and emits whichever
  12. * value it has most recently emitted since the previous sampling, unless the
  13. * source has not emitted anything since the previous sampling. The sampling
  14. * happens periodically in time every `period` milliseconds (or the time unit
  15. * defined by the optional `scheduler` argument). The sampling starts as soon as
  16. * the output Observable is subscribed.
  17. *
  18. * ## Example
  19. *
  20. * Every second, emit the most recent click at most once
  21. *
  22. * ```ts
  23. * import { fromEvent, sampleTime } from 'rxjs';
  24. *
  25. * const clicks = fromEvent(document, 'click');
  26. * const result = clicks.pipe(sampleTime(1000));
  27. *
  28. * result.subscribe(x => console.log(x));
  29. * ```
  30. *
  31. * @see {@link auditTime}
  32. * @see {@link debounceTime}
  33. * @see {@link delay}
  34. * @see {@link sample}
  35. * @see {@link throttleTime}
  36. *
  37. * @param period The sampling period expressed in milliseconds or the time unit
  38. * determined internally by the optional `scheduler`.
  39. * @param scheduler The {@link SchedulerLike} to use for managing the timers
  40. * that handle the sampling.
  41. * @return A function that returns an Observable that emits the results of
  42. * sampling the values emitted by the source Observable at the specified time
  43. * interval.
  44. */
  45. export declare function sampleTime<T>(period: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
  46. //# sourceMappingURL=sampleTime.d.ts.map