import { Observable } from '../Observable'; import { SchedulerLike } from '../types'; /** * The same Observable instance returned by any call to {@link empty} without a * `scheduler`. It is preferrable to use this over `empty()`. */ export const EMPTY = new Observable<never>(subscriber => subscriber.complete()); /** * Creates an Observable that emits no items to the Observer and immediately * emits a complete notification. * * <span class="informal">Just emits 'complete', and nothing else. * </span> * *  * * This static operator is useful for creating a simple Observable that only * emits the complete notification. It can be used for composing with other * Observables, such as in a {@link mergeMap}. * * ## Examples * ### Emit the number 7, then complete * ```ts * import { empty } from 'rxjs'; * import { startWith } from 'rxjs/operators'; * * const result = empty().pipe(startWith(7)); * result.subscribe(x => console.log(x)); * ``` * * ### Map and flatten only odd numbers to the sequence 'a', 'b', 'c' * ```ts * import { empty, interval, of } from 'rxjs'; * import { mergeMap } from 'rxjs/operators'; * * const interval$ = interval(1000); * const result = interval$.pipe( * mergeMap(x => x % 2 === 1 ? of('a', 'b', 'c') : empty()), * ); * result.subscribe(x => console.log(x)); * * // Results in the following to the console: * // x is equal to the count on the interval eg(0,1,2,3,...) * // x will occur every 1000ms * // if x % 2 is equal to 1 print abc * // if x % 2 is not equal to 1 nothing will be output * ``` * * @see {@link Observable} * @see {@link never} * @see {@link of} * @see {@link throwError} * * @param scheduler A {@link SchedulerLike} to use for scheduling * the emission of the complete notification. * @return An "empty" Observable: emits only the complete * notification. * @deprecated Deprecated in favor of using {@link EMPTY} constant, or {@link scheduled} (e.g. `scheduled([], scheduler)`) */ export function empty(scheduler?: SchedulerLike) { return scheduler ? emptyScheduled(scheduler) : EMPTY; } function emptyScheduled(scheduler: SchedulerLike) { return new Observable<never>(subscriber => scheduler.schedule(() => subscriber.complete())); }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
dom | Folder | 0755 |
|
|
ConnectableObservable.ts | File | 5.42 KB | 0644 |
|
SubscribeOnObservable.ts | File | 1.59 KB | 0644 |
|
bindCallback.ts | File | 15.9 KB | 0644 |
|
bindNodeCallback.ts | File | 15.41 KB | 0644 |
|
combineLatest.ts | File | 21.95 KB | 0644 |
|
concat.ts | File | 9.43 KB | 0644 |
|
defer.ts | File | 2.53 KB | 0644 |
|
empty.ts | File | 2.21 KB | 0644 |
|
forkJoin.ts | File | 9.49 KB | 0644 |
|
from.ts | File | 3.06 KB | 0644 |
|
fromArray.ts | File | 423 B | 0644 |
|
fromEvent.ts | File | 10.38 KB | 0644 |
|
fromEventPattern.ts | File | 7.14 KB | 0644 |
|
fromIterable.ts | File | 511 B | 0644 |
|
fromObservable.ts | File | 485 B | 0644 |
|
fromPromise.ts | File | 439 B | 0644 |
|
generate.ts | File | 12.55 KB | 0644 |
|
iif.ts | File | 3.22 KB | 0644 |
|
interval.ts | File | 2.53 KB | 0644 |
|
merge.ts | File | 9.94 KB | 0644 |
|
never.ts | File | 1.16 KB | 0644 |
|
of.ts | File | 4.77 KB | 0644 |
|
onErrorResumeNext.ts | File | 3.83 KB | 0644 |
|
pairs.ts | File | 3.06 KB | 0644 |
|
partition.ts | File | 2.61 KB | 0644 |
|
race.ts | File | 5.03 KB | 0644 |
|
range.ts | File | 2.28 KB | 0644 |
|
throwError.ts | File | 2.2 KB | 0644 |
|
timer.ts | File | 3.32 KB | 0644 |
|
using.ts | File | 3.04 KB | 0644 |
|
zip.ts | File | 12.06 KB | 0644 |
|