Front end of the Slack clone application.

throttleTime.d.ts 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { Observable } from '../Observable';
  2. import { IScheduler } from '../Scheduler';
  3. import { ThrottleConfig } from '../operators/throttle';
  4. /**
  5. * Emits a value from the source Observable, then ignores subsequent source
  6. * values for `duration` milliseconds, then repeats this process.
  7. *
  8. * <span class="informal">Lets a value pass, then ignores source values for the
  9. * next `duration` milliseconds.</span>
  10. *
  11. * <img src="./img/throttleTime.png" width="100%">
  12. *
  13. * `throttleTime` 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. After `duration` milliseconds (or the time unit determined
  18. * internally by the optional `scheduler`) has passed, the timer is disabled,
  19. * and this process repeats for the next source value. Optionally takes a
  20. * {@link IScheduler} for managing timers.
  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.throttleTime(1000);
  25. * result.subscribe(x => console.log(x));
  26. *
  27. * @see {@link auditTime}
  28. * @see {@link debounceTime}
  29. * @see {@link delay}
  30. * @see {@link sampleTime}
  31. * @see {@link throttle}
  32. *
  33. * @param {number} duration Time to wait before emitting another value after
  34. * emitting the last value, measured in milliseconds or the time unit determined
  35. * internally by the optional `scheduler`.
  36. * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for
  37. * managing the timers that handle the throttling.
  38. * @return {Observable<T>} An Observable that performs the throttle operation to
  39. * limit the rate of emissions from the source.
  40. * @method throttleTime
  41. * @owner Observable
  42. */
  43. export declare function throttleTime<T>(this: Observable<T>, duration: number, scheduler?: IScheduler, config?: ThrottleConfig): Observable<T>;