Front end of the Slack clone application.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. var throttle_1 = require('../operators/throttle');
  3. /**
  4. * Emits a value from the source Observable, then ignores subsequent source
  5. * values for a duration determined by another Observable, then repeats this
  6. * process.
  7. *
  8. * <span class="informal">It's like {@link throttleTime}, but the silencing
  9. * duration is determined by a second Observable.</span>
  10. *
  11. * <img src="./img/throttle.png" width="100%">
  12. *
  13. * `throttle` emits the source Observable values on the output Observable
  14. * when its internal timer is disabled, and ignores source values when the timer
  15. * is enabled. Initially, the timer is disabled. As soon as the first source
  16. * value arrives, it is forwarded to the output Observable, and then the timer
  17. * is enabled by calling the `durationSelector` function with the source value,
  18. * which returns the "duration" Observable. When the duration Observable emits a
  19. * value or completes, the timer is disabled, and this process repeats for the
  20. * next source value.
  21. *
  22. * @example <caption>Emit clicks at a rate of at most one click per second</caption>
  23. * var clicks = Rx.Observable.fromEvent(document, 'click');
  24. * var result = clicks.throttle(ev => Rx.Observable.interval(1000));
  25. * result.subscribe(x => console.log(x));
  26. *
  27. * @see {@link audit}
  28. * @see {@link debounce}
  29. * @see {@link delayWhen}
  30. * @see {@link sample}
  31. * @see {@link throttleTime}
  32. *
  33. * @param {function(value: T): SubscribableOrPromise} durationSelector A function
  34. * that receives a value from the source Observable, for computing the silencing
  35. * duration for each source value, returned as an Observable or a Promise.
  36. * @param {Object} config a configuration object to define `leading` and `trailing` behavior. Defaults
  37. * to `{ leading: true, trailing: false }`.
  38. * @return {Observable<T>} An Observable that performs the throttle operation to
  39. * limit the rate of emissions from the source.
  40. * @method throttle
  41. * @owner Observable
  42. */
  43. function throttle(durationSelector, config) {
  44. if (config === void 0) { config = throttle_1.defaultThrottleConfig; }
  45. return throttle_1.throttle(durationSelector, config)(this);
  46. }
  47. exports.throttle = throttle;
  48. //# sourceMappingURL=throttle.js.map