Front end of the Slack clone application.

debounceTime.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. var async_1 = require('../scheduler/async');
  3. var debounceTime_1 = require('../operators/debounceTime');
  4. /**
  5. * Emits a value from the source Observable only after a particular time span
  6. * has passed without another source emission.
  7. *
  8. * <span class="informal">It's like {@link delay}, but passes only the most
  9. * recent value from each burst of emissions.</span>
  10. *
  11. * <img src="./img/debounceTime.png" width="100%">
  12. *
  13. * `debounceTime` delays values emitted by the source Observable, but drops
  14. * previous pending delayed emissions if a new value arrives on the source
  15. * Observable. This operator keeps track of the most recent value from the
  16. * source Observable, and emits that only when `dueTime` enough time has passed
  17. * without any other value appearing on the source Observable. If a new value
  18. * appears before `dueTime` silence occurs, the previous value will be dropped
  19. * and will not be emitted on the output Observable.
  20. *
  21. * This is a rate-limiting operator, because it is impossible for more than one
  22. * value to be emitted in any time window of duration `dueTime`, but it is also
  23. * a delay-like operator since output emissions do not occur at the same time as
  24. * they did on the source Observable. Optionally takes a {@link IScheduler} for
  25. * managing timers.
  26. *
  27. * @example <caption>Emit the most recent click after a burst of clicks</caption>
  28. * var clicks = Rx.Observable.fromEvent(document, 'click');
  29. * var result = clicks.debounceTime(1000);
  30. * result.subscribe(x => console.log(x));
  31. *
  32. * @see {@link auditTime}
  33. * @see {@link debounce}
  34. * @see {@link delay}
  35. * @see {@link sampleTime}
  36. * @see {@link throttleTime}
  37. *
  38. * @param {number} dueTime The timeout duration in milliseconds (or the time
  39. * unit determined internally by the optional `scheduler`) for the window of
  40. * time required to wait for emission silence before emitting the most recent
  41. * source value.
  42. * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for
  43. * managing the timers that handle the timeout for each value.
  44. * @return {Observable} An Observable that delays the emissions of the source
  45. * Observable by the specified `dueTime`, and may drop some values if they occur
  46. * too frequently.
  47. * @method debounceTime
  48. * @owner Observable
  49. */
  50. function debounceTime(dueTime, scheduler) {
  51. if (scheduler === void 0) { scheduler = async_1.async; }
  52. return debounceTime_1.debounceTime(dueTime, scheduler)(this);
  53. }
  54. exports.debounceTime = debounceTime;
  55. //# sourceMappingURL=debounceTime.js.map