Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1023 bytes
|
Line | |
---|
1 | import { MonoTypeOperatorFunction } from '../types';
|
---|
2 | /**
|
---|
3 | * If the source observable completes without emitting a value, it will emit
|
---|
4 | * an error. The error will be created at that time by the optional
|
---|
5 | * `errorFactory` argument, otherwise, the error will be {@link EmptyError}.
|
---|
6 | *
|
---|
7 | * ![](throwIfEmpty.png)
|
---|
8 | *
|
---|
9 | * ## Example
|
---|
10 | * ```ts
|
---|
11 | * import { fromEvent, timer } from 'rxjs';
|
---|
12 | * import { throwIfEmpty, takeUntil } from 'rxjs/operators';
|
---|
13 | *
|
---|
14 | * const click$ = fromEvent(document, 'click');
|
---|
15 | *
|
---|
16 | * click$.pipe(
|
---|
17 | * takeUntil(timer(1000)),
|
---|
18 | * throwIfEmpty(
|
---|
19 | * () => new Error('the document was not clicked within 1 second')
|
---|
20 | * ),
|
---|
21 | * )
|
---|
22 | * .subscribe({
|
---|
23 | * next() { console.log('The button was clicked'); },
|
---|
24 | * error(err) { console.error(err); }
|
---|
25 | * });
|
---|
26 | * ```
|
---|
27 | *
|
---|
28 | * @param errorFactory A factory function called to produce the
|
---|
29 | * error to be thrown when the source observable completes without emitting a
|
---|
30 | * value.
|
---|
31 | */
|
---|
32 | export declare function throwIfEmpty<T>(errorFactory?: (() => any)): MonoTypeOperatorFunction<T>;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.