source: trip-planner-front/node_modules/rxjs/src/internal/operators/ignoreElements.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import { Observable } from '../Observable';
2import { Operator } from '../Operator';
3import { Subscriber } from '../Subscriber';
4import { OperatorFunction } from '../types';
5
6/**
7 * Ignores all items emitted by the source Observable and only passes calls of `complete` or `error`.
8 *
9 * ![](ignoreElements.png)
10 *
11 * ## Examples
12 * ### Ignores emitted values, reacts to observable's completion.
13 * ```ts
14 * import { of } from 'rxjs';
15 * import { ignoreElements } from 'rxjs/operators';
16 *
17 * of('you', 'talking', 'to', 'me').pipe(
18 * ignoreElements(),
19 * )
20 * .subscribe(
21 * word => console.log(word),
22 * err => console.log('error:', err),
23 * () => console.log('the end'),
24 * );
25 * // result:
26 * // 'the end'
27 * ```
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
31 * @owner Observable
32 */
33export function ignoreElements(): OperatorFunction<any, never> {
34 return function ignoreElementsOperatorFunction(source: Observable<any>) {
35 return source.lift(new IgnoreElementsOperator());
36 };
37}
38
39class IgnoreElementsOperator<T, R> implements Operator<T, R> {
40 call(subscriber: Subscriber<R>, source: any): any {
41 return source.subscribe(new IgnoreElementsSubscriber(subscriber));
42 }
43}
44
45/**
46 * We need this JSDoc comment for affecting ESDoc.
47 * @ignore
48 * @extends {Ignored}
49 */
50class IgnoreElementsSubscriber<T> extends Subscriber<T> {
51 protected _next(unused: T): void {
52 // Do nothing
53 }
54}
Note: See TracBrowser for help on using the repository browser.