Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

isEmpty.d.ts 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. * ```javascript
  24. * import { Subject } from 'rxjs';
  25. * import { isEmpty } from 'rxjs/operators';
  26. *
  27. * const source = new Subject<string>();
  28. * const result = source.pipe(isEmpty());
  29. * source.subscribe(x => console.log(x));
  30. * result.subscribe(x => console.log(x));
  31. * source.next('a');
  32. * source.next('b');
  33. * source.next('c');
  34. * source.complete();
  35. *
  36. * // Results in:
  37. * // a
  38. * // false
  39. * // b
  40. * // c
  41. * ```
  42. *
  43. * Emit `true` for an empty Observable
  44. * ```javascript
  45. * import { EMPTY } from 'rxjs';
  46. * import { isEmpty } from 'rxjs/operators';
  47. *
  48. * const result = EMPTY.pipe(isEmpty());
  49. * result.subscribe(x => console.log(x));
  50. * // Results in:
  51. * // true
  52. * ```
  53. *
  54. * @see {@link count}
  55. * @see {@link EMPTY}
  56. *
  57. * @return {OperatorFunction<T, boolean>} An Observable of a boolean value indicating whether observable was empty or not
  58. * @method isEmpty
  59. * @owner Observable
  60. */
  61. export declare function isEmpty<T>(): OperatorFunction<T, boolean>;