92daa282e9c6f4df3ba1a67cddeef447a59af844c33a9265cb1110d470de44933895bcedc40237bd36bca1a4b20dc1593e4946fec59496f389b4584ab119ee 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
  2. /**
  3. * Ignores source values for `duration` milliseconds, then emits the most recent
  4. * value from the source Observable, then repeats this process.
  5. *
  6. * <span class="informal">When it sees a source value, it ignores that plus
  7. * the next ones for `duration` milliseconds, and then it emits the most recent
  8. * value from the source.</span>
  9. *
  10. * ![](auditTime.png)
  11. *
  12. * `auditTime` is similar to `throttleTime`, but emits the last value from the
  13. * silenced time window, instead of the first value. `auditTime` emits the most
  14. * recent value from the source Observable on the output Observable as soon as
  15. * its internal timer becomes disabled, and ignores source values while the
  16. * timer is enabled. Initially, the timer is disabled. As soon as the first
  17. * source value arrives, the timer is enabled. After `duration` milliseconds (or
  18. * the time unit determined internally by the optional `scheduler`) has passed,
  19. * the timer is disabled, then the most recent source value is emitted on the
  20. * output Observable, and this process repeats for the next source value.
  21. * Optionally takes a {@link SchedulerLike} for managing timers.
  22. *
  23. * ## Example
  24. *
  25. * Emit clicks at a rate of at most one click per second
  26. *
  27. * ```ts
  28. * import { fromEvent, auditTime } from 'rxjs';
  29. *
  30. * const clicks = fromEvent(document, 'click');
  31. * const result = clicks.pipe(auditTime(1000));
  32. * result.subscribe(x => console.log(x));
  33. * ```
  34. *
  35. * @see {@link audit}
  36. * @see {@link debounceTime}
  37. * @see {@link delay}
  38. * @see {@link sampleTime}
  39. * @see {@link throttleTime}
  40. *
  41. * @param duration Time to wait before emitting the most recent source value,
  42. * measured in milliseconds or the time unit determined internally by the
  43. * optional `scheduler`.
  44. * @param scheduler The {@link SchedulerLike} to use for managing the timers
  45. * that handle the rate-limiting behavior.
  46. * @return A function that returns an Observable that performs rate-limiting of
  47. * emissions from the source Observable.
  48. */
  49. export declare function auditTime<T>(duration: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
  50. //# sourceMappingURL=auditTime.d.ts.map