UNPKG

1.78 kBTypeScriptView Raw
1import { 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 *
24 * ```ts
25 * import { Subject, isEmpty } from 'rxjs';
26 *
27 * const source = new Subject<string>();
28 * const result = source.pipe(isEmpty());
29 *
30 * source.subscribe(x => console.log(x));
31 * result.subscribe(x => console.log(x));
32 *
33 * source.next('a');
34 * source.next('b');
35 * source.next('c');
36 * source.complete();
37 *
38 * // Outputs
39 * // 'a'
40 * // false
41 * // 'b'
42 * // 'c'
43 * ```
44 *
45 * Emit `true` for an empty Observable
46 *
47 * ```ts
48 * import { EMPTY, isEmpty } from 'rxjs';
49 *
50 * const result = EMPTY.pipe(isEmpty());
51 * result.subscribe(x => console.log(x));
52 *
53 * // Outputs
54 * // true
55 * ```
56 *
57 * @see {@link count}
58 * @see {@link EMPTY}
59 *
60 * @return A function that returns an Observable that emits boolean value
61 * indicating whether the source Observable was empty or not.
62 */
63export declare function isEmpty<T>(): OperatorFunction<T, boolean>;
64//# sourceMappingURL=isEmpty.d.ts.map
\No newline at end of file