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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. * ```javascript
  28. * const clicks = fromEvent(document, 'click');
  29. * const result = clicks.pipe(debounce(() => interval(1000)));
  30. * result.subscribe(x => console.log(x));
  31. * ```
  32. *
  33. * @see {@link audit}
  34. * @see {@link debounceTime}
  35. * @see {@link delayWhen}
  36. * @see {@link throttle}
  37. *
  38. * @param {function(value: T): SubscribableOrPromise} durationSelector A function
  39. * that receives a value from the source Observable, for computing the timeout
  40. * duration for each source value, returned as an Observable or a Promise.
  41. * @return {Observable} An Observable that delays the emissions of the source
  42. * Observable by the specified duration Observable returned by
  43. * `durationSelector`, and may drop some values if they occur too frequently.
  44. * @method debounce
  45. * @owner Observable
  46. */
  47. export declare function debounce<T>(durationSelector: (value: T) => SubscribableOrPromise<any>): MonoTypeOperatorFunction<T>;