186719786203f3b45e23adf43b46a00d5aeb76ac0bdd698d9f6da80ceaca69af5cd93c593eeaf768a8344660a5efe6fbe045f35bd71a28de0f2d682b9d763f 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
  2. /**
  3. * Emits a notification from the source Observable only after a particular time span
  4. * has passed without another source emission.
  5. *
  6. * <span class="informal">It's like {@link delay}, but passes only the most
  7. * recent notification from each burst of emissions.</span>
  8. *
  9. * ![](debounceTime.png)
  10. *
  11. * `debounceTime` delays notifications emitted by the source Observable, but drops
  12. * previous pending delayed emissions if a new notification arrives on the source
  13. * Observable. This operator keeps track of the most recent notification from the
  14. * source Observable, and emits that only when `dueTime` has passed
  15. * without any other notification appearing on the source Observable. If a new value
  16. * appears before `dueTime` silence occurs, the previous notification will be dropped
  17. * and will not be emitted and a new `dueTime` is scheduled.
  18. * If the completing event happens during `dueTime` the last cached notification
  19. * is emitted before the completion event is forwarded to the output observable.
  20. * If the error event happens during `dueTime` or after it only the error event is
  21. * forwarded to the output observable. The cache notification is not emitted in this case.
  22. *
  23. * This is a rate-limiting operator, because it is impossible for more than one
  24. * notification to be emitted in any time window of duration `dueTime`, but it is also
  25. * a delay-like operator since output emissions do not occur at the same time as
  26. * they did on the source Observable. Optionally takes a {@link SchedulerLike} for
  27. * managing timers.
  28. *
  29. * ## Example
  30. *
  31. * Emit the most recent click after a burst of clicks
  32. *
  33. * ```ts
  34. * import { fromEvent, debounceTime } from 'rxjs';
  35. *
  36. * const clicks = fromEvent(document, 'click');
  37. * const result = clicks.pipe(debounceTime(1000));
  38. * result.subscribe(x => console.log(x));
  39. * ```
  40. *
  41. * @see {@link audit}
  42. * @see {@link auditTime}
  43. * @see {@link debounce}
  44. * @see {@link sample}
  45. * @see {@link sampleTime}
  46. * @see {@link throttle}
  47. * @see {@link throttleTime}
  48. *
  49. * @param dueTime The timeout duration in milliseconds (or the time unit determined
  50. * internally by the optional `scheduler`) for the window of time required to wait
  51. * for emission silence before emitting the most recent source value.
  52. * @param scheduler The {@link SchedulerLike} to use for managing the timers that
  53. * handle the timeout for each value.
  54. * @return A function that returns an Observable that delays the emissions of
  55. * the source Observable by the specified `dueTime`, and may drop some values
  56. * if they occur too frequently.
  57. */
  58. export declare function debounceTime<T>(dueTime: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
  59. //# sourceMappingURL=debounceTime.d.ts.map