UNPKG

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