Debian Codegraph @

src/main/java/io/reactivex/rxjava3/internal/operators/observable/ObservableIgnoreElementsCompletable.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 import io.reactivex.rxjava3.internal.fuseable.FuseToObservable;
19 import io.reactivex.rxjava3.plugins.RxJavaPlugins;
20
21 public final class ObservableIgnoreElementsCompletable<T> extends Completable implements FuseToObservable<T> {
22
23 final ObservableSource<T> source;
24
25 public ObservableIgnoreElementsCompletable(ObservableSource<T> source) {
26 this.source = source;
27 }
28
29 @Override
30 public void subscribeActual(final CompletableObserver t) {
31 source.subscribe(new IgnoreObservable<>(t));
32 }
33
34 @Override
35 public Observable<T> fuseToObservable() {
36 return RxJavaPlugins.onAssembly(new ObservableIgnoreElements<>(source));
37 }
38
39 static final class IgnoreObservable<T> implements Observer<T>, Disposable {
40 final CompletableObserver downstream;
41
42 Disposable upstream;
43
44 IgnoreObservable(CompletableObserver t) {
45 this.downstream = t;
46 }
47
48 @Override
49 public void onSubscribe(Disposable d) {
50 this.upstream = d;
51 downstream.onSubscribe(this);
52 }
53
54 @Override
55 public void onNext(T v) {
56 // deliberately ignored
57 }
58
59 @Override
60 public void onError(Throwable e) {
61 downstream.onError(e);
62 }
63
64 @Override
65 public void onComplete() {
66 downstream.onComplete();
67 }
68
69 @Override
70 public void dispose() {
71 upstream.dispose();
72 }
73
74 @Override
75 public boolean isDisposed() {
76 return upstream.isDisposed();
77 }
78 }
79
80 }