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

never.ts 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Observable } from '../Observable';
  2. import { noop } from '../util/noop';
  3. /**
  4. * An Observable that emits no items to the Observer and never completes.
  5. *
  6. * ![](never.png)
  7. *
  8. * A simple Observable that emits neither values nor errors nor the completion
  9. * notification. It can be used for testing purposes or for composing with other
  10. * Observables. Please note that by never emitting a complete notification, this
  11. * Observable keeps the subscription from being disposed automatically.
  12. * Subscriptions need to be manually disposed.
  13. *
  14. * ## Example
  15. * ### Emit the number 7, then never emit anything else (not even complete)
  16. * ```ts
  17. * import { NEVER } from 'rxjs';
  18. * import { startWith } from 'rxjs/operators';
  19. *
  20. * function info() {
  21. * console.log('Will not be called');
  22. * }
  23. * const result = NEVER.pipe(startWith(7));
  24. * result.subscribe(x => console.log(x), info, info);
  25. *
  26. * ```
  27. *
  28. * @see {@link Observable}
  29. * @see {@link index/EMPTY}
  30. * @see {@link of}
  31. * @see {@link throwError}
  32. */
  33. export const NEVER = new Observable<never>(noop);
  34. /**
  35. * @deprecated Deprecated in favor of using {@link NEVER} constant.
  36. */
  37. export function never () {
  38. return NEVER;
  39. }