Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

audit.d.ts 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { MonoTypeOperatorFunction, SubscribableOrPromise } from '../types';
  2. /**
  3. * Ignores source values for a duration determined by another Observable, then
  4. * emits the most recent value from the source Observable, then repeats this
  5. * process.
  6. *
  7. * <span class="informal">It's like {@link auditTime}, but the silencing
  8. * duration is determined by a second Observable.</span>
  9. *
  10. * ![](audit.png)
  11. *
  12. * `audit` is similar to `throttle`, but emits the last value from the silenced
  13. * time window, instead of the first value. `audit` emits the most recent value
  14. * from the source Observable on the output Observable as soon as its internal
  15. * timer becomes disabled, and ignores source values while the timer is enabled.
  16. * Initially, the timer is disabled. As soon as the first source value arrives,
  17. * the timer is enabled by calling the `durationSelector` function with the
  18. * source value, which returns the "duration" Observable. When the duration
  19. * Observable emits a value or completes, the timer is disabled, then the most
  20. * recent source value is emitted on the output Observable, and this process
  21. * repeats for the next source value.
  22. *
  23. * ## Example
  24. *
  25. * Emit clicks at a rate of at most one click per second
  26. * ```javascript
  27. * const clicks = fromEvent(document, 'click');
  28. * const result = clicks.pipe(audit(ev => interval(1000)));
  29. * result.subscribe(x => console.log(x));
  30. * ```
  31. * @see {@link auditTime}
  32. * @see {@link debounce}
  33. * @see {@link delayWhen}
  34. * @see {@link sample}
  35. * @see {@link throttle}
  36. *
  37. * @param {function(value: T): SubscribableOrPromise} durationSelector A function
  38. * that receives a value from the source Observable, for computing the silencing
  39. * duration, returned as an Observable or a Promise.
  40. * @return {Observable<T>} An Observable that performs rate-limiting of
  41. * emissions from the source Observable.
  42. * @method audit
  43. * @owner Observable
  44. */
  45. export declare function audit<T>(durationSelector: (value: T) => SubscribableOrPromise<any>): MonoTypeOperatorFunction<T>;