84fc6924bbc6d7b4b503e746ec1cd73835b535d1ea8d19e1b0f03d61b65c751f0bc7064edd35680c3aa93995a0dc31019b316d1bbfe275bedeaebc16df1205 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { MonoTypeOperatorFunction } from '../types';
  2. /**
  3. * Emits only the first `count` values emitted by the source Observable.
  4. *
  5. * <span class="informal">Takes the first `count` values from the source, then
  6. * completes.</span>
  7. *
  8. * ![](take.png)
  9. *
  10. * `take` returns an Observable that emits only the first `count` values emitted
  11. * by the source Observable. If the source emits fewer than `count` values then
  12. * all of its values are emitted. After that, it completes, regardless if the
  13. * source completes.
  14. *
  15. * ## Example
  16. *
  17. * Take the first 5 seconds of an infinite 1-second interval Observable
  18. *
  19. * ```ts
  20. * import { interval, take } from 'rxjs';
  21. *
  22. * const intervalCount = interval(1000);
  23. * const takeFive = intervalCount.pipe(take(5));
  24. * takeFive.subscribe(x => console.log(x));
  25. *
  26. * // Logs:
  27. * // 0
  28. * // 1
  29. * // 2
  30. * // 3
  31. * // 4
  32. * ```
  33. *
  34. * @see {@link takeLast}
  35. * @see {@link takeUntil}
  36. * @see {@link takeWhile}
  37. * @see {@link skip}
  38. *
  39. * @param count The maximum number of `next` values to emit.
  40. * @return A function that returns an Observable that emits only the first
  41. * `count` values emitted by the source Observable, or all of the values from
  42. * the source if the source emits fewer than `count` values.
  43. */
  44. export declare function take<T>(count: number): MonoTypeOperatorFunction<T>;
  45. //# sourceMappingURL=take.d.ts.map