Front end of the Slack clone application.

debounceTime.d.ts 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { IScheduler } from '../Scheduler';
  2. import { MonoTypeOperatorFunction } from '../interfaces';
  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 declare function debounceTime<T>(dueTime: number, scheduler?: IScheduler): MonoTypeOperatorFunction<T>;