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.

debounce.d.ts 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { MonoTypeOperatorFunction, SubscribableOrPromise } from '../types';
  2. /**
  3. * Emits a value from the source Observable only after a particular time span
  4. * determined by another Observable has passed without another source emission.
  5. *
  6. * <span class="informal">It's like {@link debounceTime}, but the time span of
  7. * emission silence is determined by a second Observable.</span>
  8. *
  9. * ![](debounce.png)
  10. *
  11. * `debounce` delays values emitted by the source Observable, but drops previous
  12. * pending delayed emissions if a new value arrives on the source Observable.
  13. * This operator keeps track of the most recent value from the source
  14. * Observable, and spawns a duration Observable by calling the
  15. * `durationSelector` function. The value is emitted only when the duration
  16. * Observable emits a value or completes, and if no other value was emitted on
  17. * the source Observable since the duration Observable was spawned. If a new
  18. * value appears before the duration Observable emits, the previous value will
  19. * be dropped and will not be emitted on the output Observable.
  20. *
  21. * Like {@link debounceTime}, this is a rate-limiting operator, and also a
  22. * delay-like operator since output emissions do not necessarily occur at the
  23. * same time as they did on the source Observable.
  24. *
  25. * ## Example
  26. * Emit the most recent click after a burst of clicks
  27. * ```ts
  28. * import { fromEvent, interval } from 'rxjs';
  29. * import { debounce } from 'rxjs/operators';
  30. *
  31. * const clicks = fromEvent(document, 'click');
  32. * const result = clicks.pipe(debounce(() => interval(1000)));
  33. * result.subscribe(x => console.log(x));
  34. * ```
  35. *
  36. * @see {@link audit}
  37. * @see {@link debounceTime}
  38. * @see {@link delayWhen}
  39. * @see {@link throttle}
  40. *
  41. * @param {function(value: T): SubscribableOrPromise} durationSelector A function
  42. * that receives a value from the source Observable, for computing the timeout
  43. * duration for each source value, returned as an Observable or a Promise.
  44. * @return {Observable} An Observable that delays the emissions of the source
  45. * Observable by the specified duration Observable returned by
  46. * `durationSelector`, and may drop some values if they occur too frequently.
  47. * @method debounce
  48. * @owner Observable
  49. */
  50. export declare function debounce<T>(durationSelector: (value: T) => SubscribableOrPromise<any>): MonoTypeOperatorFunction<T>;