71b220e76f6c89b6964c702c62d6647cba2f56f01304a4e4f92400c40db2a29480973a471d5a0134fbed42cd4c1841c934bcacff7321475eb66371d613c073 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { ThrottleConfig } from './throttle';
  2. import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
  3. /**
  4. * Emits a value from the source Observable, then ignores subsequent source
  5. * values for `duration` milliseconds, then repeats this process.
  6. *
  7. * <span class="informal">Lets a value pass, then ignores source values for the
  8. * next `duration` milliseconds.</span>
  9. *
  10. * ![](throttleTime.png)
  11. *
  12. * `throttleTime` emits the source Observable values on the output Observable
  13. * when its internal timer is disabled, and ignores source values when the timer
  14. * is enabled. Initially, the timer is disabled. As soon as the first source
  15. * value arrives, it is forwarded to the output Observable, and then the timer
  16. * is enabled. After `duration` milliseconds (or the time unit determined
  17. * internally by the optional `scheduler`) has passed, the timer is disabled,
  18. * and this process repeats for the next source value. Optionally takes a
  19. * {@link SchedulerLike} for managing timers.
  20. *
  21. * ## Examples
  22. *
  23. * ### Limit click rate
  24. *
  25. * Emit clicks at a rate of at most one click per second
  26. *
  27. * ```ts
  28. * import { fromEvent, throttleTime } from 'rxjs';
  29. *
  30. * const clicks = fromEvent(document, 'click');
  31. * const result = clicks.pipe(throttleTime(1000));
  32. *
  33. * result.subscribe(x => console.log(x));
  34. * ```
  35. *
  36. * @see {@link auditTime}
  37. * @see {@link debounceTime}
  38. * @see {@link delay}
  39. * @see {@link sampleTime}
  40. * @see {@link throttle}
  41. *
  42. * @param duration Time to wait before emitting another value after
  43. * emitting the last value, measured in milliseconds or the time unit determined
  44. * internally by the optional `scheduler`.
  45. * @param scheduler The {@link SchedulerLike} to use for
  46. * managing the timers that handle the throttling. Defaults to {@link asyncScheduler}.
  47. * @param config A configuration object to define `leading` and
  48. * `trailing` behavior. Defaults to `{ leading: true, trailing: false }`.
  49. * @return A function that returns an Observable that performs the throttle
  50. * operation to limit the rate of emissions from the source.
  51. */
  52. export declare function throttleTime<T>(duration: number, scheduler?: SchedulerLike, config?: ThrottleConfig): MonoTypeOperatorFunction<T>;
  53. //# sourceMappingURL=throttleTime.d.ts.map