Debian Codegraph @

node/rxjs/src/internal/observable/never.ts

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