a zip code crypto-currency system good for red ONLY

sampleTime.js 1.9KB

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