UNPKG

2.04 kBTypeScriptView Raw
1import { Observable } from '../Observable';
2import { SchedulerLike } from '../types';
3/**
4 * A simple Observable that emits no items to the Observer and immediately
5 * emits a complete notification.
6 *
7 * <span class="informal">Just emits 'complete', and nothing else.</span>
8 *
9 * ![](empty.png)
10 *
11 * A simple Observable that only emits the complete notification. It can be used
12 * for composing with other Observables, such as in a {@link mergeMap}.
13 *
14 * ## Examples
15 *
16 * Log complete notification
17 *
18 * ```ts
19 * import { EMPTY } from 'rxjs';
20 *
21 * EMPTY.subscribe({
22 * next: () => console.log('Next'),
23 * complete: () => console.log('Complete!')
24 * });
25 *
26 * // Outputs
27 * // Complete!
28 * ```
29 *
30 * Emit the number 7, then complete
31 *
32 * ```ts
33 * import { EMPTY, startWith } from 'rxjs';
34 *
35 * const result = EMPTY.pipe(startWith(7));
36 * result.subscribe(x => console.log(x));
37 *
38 * // Outputs
39 * // 7
40 * ```
41 *
42 * Map and flatten only odd numbers to the sequence `'a'`, `'b'`, `'c'`
43 *
44 * ```ts
45 * import { interval, mergeMap, of, EMPTY } from 'rxjs';
46 *
47 * const interval$ = interval(1000);
48 * const result = interval$.pipe(
49 * mergeMap(x => x % 2 === 1 ? of('a', 'b', 'c') : EMPTY),
50 * );
51 * result.subscribe(x => console.log(x));
52 *
53 * // Results in the following to the console:
54 * // x is equal to the count on the interval, e.g. (0, 1, 2, 3, ...)
55 * // x will occur every 1000ms
56 * // if x % 2 is equal to 1, print a, b, c (each on its own)
57 * // if x % 2 is not equal to 1, nothing will be output
58 * ```
59 *
60 * @see {@link Observable}
61 * @see {@link NEVER}
62 * @see {@link of}
63 * @see {@link throwError}
64 */
65export declare const EMPTY: Observable<never>;
66/**
67 * @param scheduler A {@link SchedulerLike} to use for scheduling
68 * the emission of the complete notification.
69 * @deprecated Replaced with the {@link EMPTY} constant or {@link scheduled} (e.g. `scheduled([], scheduler)`). Will be removed in v8.
70 */
71export declare function empty(scheduler?: SchedulerLike): Observable<never>;
72//# sourceMappingURL=empty.d.ts.map
\No newline at end of file