1 | import { Observable } from '../Observable';
|
---|
2 | import { SchedulerLike } from '../types';
|
---|
3 | /**
|
---|
4 | * The same Observable instance returned by any call to {@link empty} without a
|
---|
5 | * `scheduler`. It is preferrable to use this over `empty()`.
|
---|
6 | */
|
---|
7 | export declare const EMPTY: Observable<never>;
|
---|
8 | /**
|
---|
9 | * Creates an Observable that emits no items to the Observer and immediately
|
---|
10 | * emits a complete notification.
|
---|
11 | *
|
---|
12 | * <span class="informal">Just emits 'complete', and nothing else.
|
---|
13 | * </span>
|
---|
14 | *
|
---|
15 | * ![](empty.png)
|
---|
16 | *
|
---|
17 | * This static operator is useful for creating a simple Observable that only
|
---|
18 | * emits the complete notification. It can be used for composing with other
|
---|
19 | * Observables, such as in a {@link mergeMap}.
|
---|
20 | *
|
---|
21 | * ## Examples
|
---|
22 | * ### Emit the number 7, then complete
|
---|
23 | * ```ts
|
---|
24 | * import { empty } from 'rxjs';
|
---|
25 | * import { startWith } from 'rxjs/operators';
|
---|
26 | *
|
---|
27 | * const result = empty().pipe(startWith(7));
|
---|
28 | * result.subscribe(x => console.log(x));
|
---|
29 | * ```
|
---|
30 | *
|
---|
31 | * ### Map and flatten only odd numbers to the sequence 'a', 'b', 'c'
|
---|
32 | * ```ts
|
---|
33 | * import { empty, interval, of } from 'rxjs';
|
---|
34 | * import { mergeMap } from 'rxjs/operators';
|
---|
35 | *
|
---|
36 | * const interval$ = interval(1000);
|
---|
37 | * const result = interval$.pipe(
|
---|
38 | * mergeMap(x => x % 2 === 1 ? of('a', 'b', 'c') : empty()),
|
---|
39 | * );
|
---|
40 | * result.subscribe(x => console.log(x));
|
---|
41 | *
|
---|
42 | * // Results in the following to the console:
|
---|
43 | * // x is equal to the count on the interval eg(0,1,2,3,...)
|
---|
44 | * // x will occur every 1000ms
|
---|
45 | * // if x % 2 is equal to 1 print abc
|
---|
46 | * // if x % 2 is not equal to 1 nothing will be output
|
---|
47 | * ```
|
---|
48 | *
|
---|
49 | * @see {@link Observable}
|
---|
50 | * @see {@link never}
|
---|
51 | * @see {@link of}
|
---|
52 | * @see {@link throwError}
|
---|
53 | *
|
---|
54 | * @param scheduler A {@link SchedulerLike} to use for scheduling
|
---|
55 | * the emission of the complete notification.
|
---|
56 | * @return An "empty" Observable: emits only the complete
|
---|
57 | * notification.
|
---|
58 | * @deprecated Deprecated in favor of using {@link EMPTY} constant, or {@link scheduled} (e.g. `scheduled([], scheduler)`)
|
---|
59 | */
|
---|
60 | export declare function empty(scheduler?: SchedulerLike): Observable<never>;
|
---|