Skip to content

Commit

Permalink
docs: move duplicate docs from empty() to EMPTY (#6746)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakovljevic-mladen committed Jan 11, 2022
1 parent c45e07c commit 17380f1
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions src/internal/observable/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { Observable } from '../Observable';
import { SchedulerLike } from '../types';

/**
* The same Observable instance returned by any call to {@link empty} without a
* `scheduler`. It is preferable to use this over `empty()`.
* A simple Observable that emits no items to the Observer and immediately
* emits a complete notification.
*
* <span class="informal">Just emits 'complete', and nothing else.</span>
*
* ![](empty.png)
*
* 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
*
* Log complete notification
Expand All @@ -24,43 +27,27 @@ import { SchedulerLike } from '../types';
* // Outputs
* // Complete!
* ```
*/
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>
*
* ![](empty.png)
*
* 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, startWith } from 'rxjs';
* import { EMPTY, startWith } from 'rxjs';
*
* const result = empty().pipe(startWith(7));
* const result = EMPTY.pipe(startWith(7));
* result.subscribe(x => console.log(x));
*
* // Outputs
* // 7
* ```
*
* Map and flatten only odd numbers to the sequence 'a', 'b', 'c'
* Map and flatten only odd numbers to the sequence `'a'`, `'b'`, `'c'`
*
* ```ts
* import { interval, mergeMap, of, empty } from 'rxjs';
* import { interval, mergeMap, of, EMPTY } from 'rxjs';
*
* const interval$ = interval(1000);
* const result = interval$.pipe(
* mergeMap(x => x % 2 === 1 ? of('a', 'b', 'c') : empty()),
* mergeMap(x => x % 2 === 1 ? of('a', 'b', 'c') : EMPTY),
* );
* result.subscribe(x => console.log(x));
*
Expand All @@ -72,14 +59,15 @@ export const EMPTY = new Observable<never>((subscriber) => subscriber.complete()
* ```
*
* @see {@link Observable}
* @see {@link never}
* @see {@link NEVER}
* @see {@link of}
* @see {@link throwError}
*
*/
export const EMPTY = new Observable<never>((subscriber) => subscriber.complete());

/**
* @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 Replaced with the {@link EMPTY} constant or {@link scheduled} (e.g. `scheduled([], scheduler)`). Will be removed in v8.
*/
export function empty(scheduler?: SchedulerLike) {
Expand Down

0 comments on commit 17380f1

Please sign in to comment.