a zip code crypto-currency system good for red ONLY

debounce.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { debounce as higherOrder } from '../operators/debounce';
  2. /**
  3. * Emits a value from the source Observable only after a particular time span
  4. * determined by another Observable has passed without another source emission.
  5. *
  6. * <span class="informal">It's like {@link debounceTime}, but the time span of
  7. * emission silence is determined by a second Observable.</span>
  8. *
  9. * <img src="./img/debounce.png" width="100%">
  10. *
  11. * `debounce` delays values emitted by the source Observable, but drops previous
  12. * pending delayed emissions if a new value arrives on the source Observable.
  13. * This operator keeps track of the most recent value from the source
  14. * Observable, and spawns a duration Observable by calling the
  15. * `durationSelector` function. The value is emitted only when the duration
  16. * Observable emits a value or completes, and if no other value was emitted on
  17. * the source Observable since the duration Observable was spawned. If a new
  18. * value appears before the duration Observable emits, the previous value will
  19. * be dropped and will not be emitted on the output Observable.
  20. *
  21. * Like {@link debounceTime}, this is a rate-limiting operator, and also a
  22. * delay-like operator since output emissions do not necessarily occur at the
  23. * same time as they did on the source Observable.
  24. *
  25. * @example <caption>Emit the most recent click after a burst of clicks</caption>
  26. * var clicks = Rx.Observable.fromEvent(document, 'click');
  27. * var result = clicks.debounce(() => Rx.Observable.interval(1000));
  28. * result.subscribe(x => console.log(x));
  29. *
  30. * @see {@link audit}
  31. * @see {@link debounceTime}
  32. * @see {@link delayWhen}
  33. * @see {@link throttle}
  34. *
  35. * @param {function(value: T): SubscribableOrPromise} durationSelector A function
  36. * that receives a value from the source Observable, for computing the timeout
  37. * duration for each source value, returned as an Observable or a Promise.
  38. * @return {Observable} An Observable that delays the emissions of the source
  39. * Observable by the specified duration Observable returned by
  40. * `durationSelector`, and may drop some values if they occur too frequently.
  41. * @method debounce
  42. * @owner Observable
  43. */
  44. export function debounce(durationSelector) {
  45. return higherOrder(durationSelector)(this);
  46. }
  47. //# sourceMappingURL=debounce.js.map