Front end of the Slack clone application.

throttleTime.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /** PURE_IMPORTS_START .._scheduler_async,.._operators_throttle,.._operators_throttleTime PURE_IMPORTS_END */
  2. import { async } from '../scheduler/async';
  3. import { defaultThrottleConfig } from '../operators/throttle';
  4. import { throttleTime as higherOrder } from '../operators/throttleTime';
  5. /**
  6. * Emits a value from the source Observable, then ignores subsequent source
  7. * values for `duration` milliseconds, then repeats this process.
  8. *
  9. * <span class="informal">Lets a value pass, then ignores source values for the
  10. * next `duration` milliseconds.</span>
  11. *
  12. * <img src="./img/throttleTime.png" width="100%">
  13. *
  14. * `throttleTime` emits the source Observable values on the output Observable
  15. * when its internal timer is disabled, and ignores source values when the timer
  16. * is enabled. Initially, the timer is disabled. As soon as the first source
  17. * value arrives, it is forwarded to the output Observable, and then the timer
  18. * is enabled. After `duration` milliseconds (or the time unit determined
  19. * internally by the optional `scheduler`) has passed, the timer is disabled,
  20. * and this process repeats for the next source value. Optionally takes a
  21. * {@link IScheduler} for managing timers.
  22. *
  23. * @example <caption>Emit clicks at a rate of at most one click per second</caption>
  24. * var clicks = Rx.Observable.fromEvent(document, 'click');
  25. * var result = clicks.throttleTime(1000);
  26. * result.subscribe(x => console.log(x));
  27. *
  28. * @see {@link auditTime}
  29. * @see {@link debounceTime}
  30. * @see {@link delay}
  31. * @see {@link sampleTime}
  32. * @see {@link throttle}
  33. *
  34. * @param {number} duration Time to wait before emitting another value after
  35. * emitting the last value, measured in milliseconds or the time unit determined
  36. * internally by the optional `scheduler`.
  37. * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for
  38. * managing the timers that handle the throttling.
  39. * @return {Observable<T>} An Observable that performs the throttle operation to
  40. * limit the rate of emissions from the source.
  41. * @method throttleTime
  42. * @owner Observable
  43. */
  44. export function throttleTime(duration, scheduler, config) {
  45. if (scheduler === void 0) {
  46. scheduler = async;
  47. }
  48. if (config === void 0) {
  49. config = defaultThrottleConfig;
  50. }
  51. return higherOrder(duration, scheduler, config)(this);
  52. }
  53. //# sourceMappingURL=throttleTime.js.map