a zip code crypto-currency system good for red ONLY

debounceTime.js 2.4KB

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