Debian Codegraph @

src/main/java/io/reactivex/rxjava3/internal/operators/observable/ObservableIgnoreElements.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.internal.operators.observable;
15
16 import io.reactivex.rxjava3.core.*;
17 import io.reactivex.rxjava3.disposables.Disposable;
18
19 public final class ObservableIgnoreElements<T> extends AbstractObservableWithUpstream<T, T> {
20
21 public ObservableIgnoreElements(ObservableSource<T> source) {
22 super(source);
23 }
24
25 @Override
26 public void subscribeActual(final Observer<? super T> t) {
27 source.subscribe(new IgnoreObservable<>(t));
28 }
29
30 static final class IgnoreObservable<T> implements Observer<T>, Disposable {
31 final Observer<? super T> downstream;
32
33 Disposable upstream;
34
35 IgnoreObservable(Observer<? super T> t) {
36 this.downstream = t;
37 }
38
39 @Override
40 public void onSubscribe(Disposable d) {
41 this.upstream = d;
42 downstream.onSubscribe(this);
43 }
44
45 @Override
46 public void onNext(T v) {
47 // deliberately ignored
48 }
49
50 @Override
51 public void onError(Throwable e) {
52 downstream.onError(e);
53 }
54
55 @Override
56 public void onComplete() {
57 downstream.onComplete();
58 }
59
60 @Override
61 public void dispose() {
62 upstream.dispose();
63 }
64
65 @Override
66 public boolean isDisposed() {
67 return upstream.isDisposed();
68 }
69 }
70
71 }