21d4ec57cba4d85d7636f5c641a7bd83155dbe1cfdf9cef63ed84504e025895c5cdf6877df49bdc1fb197a27531f99961d19ecbbed2a94c244ef0a4357bb09 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { OperatorFunction } from '../types';
  2. /**
  3. * Emits `false` if the input Observable emits any values, or emits `true` if the
  4. * input Observable completes without emitting any values.
  5. *
  6. * <span class="informal">Tells whether any values are emitted by an Observable.</span>
  7. *
  8. * ![](isEmpty.png)
  9. *
  10. * `isEmpty` transforms an Observable that emits values into an Observable that
  11. * emits a single boolean value representing whether or not any values were
  12. * emitted by the source Observable. As soon as the source Observable emits a
  13. * value, `isEmpty` will emit a `false` and complete. If the source Observable
  14. * completes having not emitted anything, `isEmpty` will emit a `true` and
  15. * complete.
  16. *
  17. * A similar effect could be achieved with {@link count}, but `isEmpty` can emit
  18. * a `false` value sooner.
  19. *
  20. * ## Examples
  21. *
  22. * Emit `false` for a non-empty Observable
  23. *
  24. * ```ts
  25. * import { Subject, isEmpty } from 'rxjs';
  26. *
  27. * const source = new Subject<string>();
  28. * const result = source.pipe(isEmpty());
  29. *
  30. * source.subscribe(x => console.log(x));
  31. * result.subscribe(x => console.log(x));
  32. *
  33. * source.next('a');
  34. * source.next('b');
  35. * source.next('c');
  36. * source.complete();
  37. *
  38. * // Outputs
  39. * // 'a'
  40. * // false
  41. * // 'b'
  42. * // 'c'
  43. * ```
  44. *
  45. * Emit `true` for an empty Observable
  46. *
  47. * ```ts
  48. * import { EMPTY, isEmpty } from 'rxjs';
  49. *
  50. * const result = EMPTY.pipe(isEmpty());
  51. * result.subscribe(x => console.log(x));
  52. *
  53. * // Outputs
  54. * // true
  55. * ```
  56. *
  57. * @see {@link count}
  58. * @see {@link EMPTY}
  59. *
  60. * @return A function that returns an Observable that emits boolean value
  61. * indicating whether the source Observable was empty or not.
  62. */
  63. export declare function isEmpty<T>(): OperatorFunction<T, boolean>;
  64. //# sourceMappingURL=isEmpty.d.ts.map