auditTime.d.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { Observable, SchedulerLike } from 'rxjs';
  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 values, 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. * <img src="./img/auditTime.png" width="100%">
  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 IScheduler} for managing timers.
  22. *
  23. * @example <caption>Emit clicks at a rate of at most one click per second</caption>
  24. * var clicks = Rx.Observable.fromEvent(document, 'click');
  25. * var result = clicks.auditTime(1000);
  26. * result.subscribe(x => console.log(x));
  27. *
  28. * @see {@link audit}
  29. * @see {@link debounceTime}
  30. * @see {@link delay}
  31. * @see {@link sampleTime}
  32. * @see {@link throttleTime}
  33. *
  34. * @param {number} duration Time to wait before emitting the most recent source
  35. * value, measured in milliseconds or the time unit determined internally
  36. * by the optional `scheduler`.
  37. * @param {Scheduler} [scheduler=async] The {@link IScheduler} to use for
  38. * managing the timers that handle the rate-limiting behavior.
  39. * @return {Observable<T>} An Observable that performs rate-limiting of
  40. * emissions from the source Observable.
  41. * @method auditTime
  42. * @owner Observable
  43. */
  44. export declare function auditTime<T>(this: Observable<T>, duration: number, scheduler?: SchedulerLike): Observable<T>;