auditTime.d.ts 2.2KB

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