1 import { Observable } from '../Observable';
2 import { Operator } from '../Operator';
3 import { Subscriber } from '../Subscriber';
4 import { OperatorFunction } from '../types';
7 * Ignores all items emitted by the source Observable and only passes calls of `complete` or `error`.
9 * ![](ignoreElements.png)
12 * ### Ignores emitted values, reacts to observable's completion.
14 * import { of } from 'rxjs';
15 * import { ignoreElements } from 'rxjs/operators';
17 * of('you', 'talking', 'to', 'me').pipe(
21 * word => console.log(word),
22 * err => console.log('error:', err),
23 * () => console.log('the end'),
28 * @return {Observable} An empty Observable that only calls `complete`
29 * or `error`, based on which one is called by the source Observable.
30 * @method ignoreElements
33 export function ignoreElements(): OperatorFunction<any, never> {
34 return function ignoreElementsOperatorFunction(source: Observable<any>) {
35 return source.lift(new IgnoreElementsOperator());
39 class IgnoreElementsOperator<T, R> implements Operator<T, R> {
40 call(subscriber: Subscriber<R>, source: any): any {
41 return source.subscribe(new IgnoreElementsSubscriber(subscriber));
46 * We need this JSDoc comment for affecting ESDoc.
50 class IgnoreElementsSubscriber<T> extends Subscriber<T> {
51 protected _next(unused: T): void {