Front end of the Slack clone application.

sampleTime.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { async } from '../scheduler/async';
  2. import { sampleTime as higherOrder } from '../operators/sampleTime';
  3. /**
  4. * Emits the most recently emitted value from the source Observable within
  5. * periodic time intervals.
  6. *
  7. * <span class="informal">Samples the source Observable at periodic time
  8. * intervals, emitting what it samples.</span>
  9. *
  10. * <img src="./img/sampleTime.png" width="100%">
  11. *
  12. * `sampleTime` periodically looks at the source Observable and emits whichever
  13. * value it has most recently emitted since the previous sampling, unless the
  14. * source has not emitted anything since the previous sampling. The sampling
  15. * happens periodically in time every `period` milliseconds (or the time unit
  16. * defined by the optional `scheduler` argument). The sampling starts as soon as
  17. * the output Observable is subscribed.
  18. *
  19. * @example <caption>Every second, emit the most recent click at most once</caption>
  20. * var clicks = Rx.Observable.fromEvent(document, 'click');
  21. * var result = clicks.sampleTime(1000);
  22. * result.subscribe(x => console.log(x));
  23. *
  24. * @see {@link auditTime}
  25. * @see {@link debounceTime}
  26. * @see {@link delay}
  27. * @see {@link sample}
  28. * @see {@link throttleTime}
  29. *
  30. * @param {number} period The sampling period expressed in milliseconds or the
  31. * time unit determined internally by the optional `scheduler`.
  32. * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for
  33. * managing the timers that handle the sampling.
  34. * @return {Observable<T>} An Observable that emits the results of sampling the
  35. * values emitted by the source Observable at the specified time interval.
  36. * @method sampleTime
  37. * @owner Observable
  38. */
  39. export function sampleTime(period, scheduler = async) {
  40. return higherOrder(period, scheduler)(this);
  41. }
  42. //# sourceMappingURL=sampleTime.js.map