Skip to content

Commit e81d399

Browse files
vanniktechakarnokd
authored andcommitted
2.x: Rename Completable Base Interface Types for consistency (ReactiveX#4302)
1 parent a549174 commit e81d399

File tree

51 files changed

+342
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+342
-311
lines changed

src/main/java/io/reactivex/Completable.java

Lines changed: 41 additions & 57 deletions
Large diffs are not rendered by default.

src/main/java/io/reactivex/CompletableSubscriber.java renamed to src/main/java/io/reactivex/CompletableObserver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* Represents the subscription API callbacks when subscribing to a Completable instance.
2020
*/
21-
public interface CompletableSubscriber {
21+
public interface CompletableObserver {
2222
/**
2323
* Called once the deferred computation completes normally.
2424
*/
@@ -36,4 +36,4 @@ public interface CompletableSubscriber {
3636
* @param d the Disposable instance to call dispose on for cancellation, not null
3737
*/
3838
void onSubscribe(Disposable d);
39-
}
39+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright 2016 Netflix, Inc.
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;
15+
16+
import io.reactivex.functions.Function;
17+
18+
/**
19+
* Convenience interface and callback used by the lift operator that given a child CompletableSubscriber,
20+
* return a parent CompletableSubscriber that does any kind of lifecycle-related transformations.
21+
*/
22+
public interface CompletableOperator extends Function<CompletableObserver, CompletableObserver> {
23+
24+
}

src/main/java/io/reactivex/CompletableConsumable.java renamed to src/main/java/io/reactivex/CompletableSource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
/**
1616
* Represents a basic {@link Completable} source base interface,
17-
* consumable via an {@link CompletableSubscriber}.
17+
* consumable via an {@link CompletableObserver}.
1818
* <p>
1919
* This class also serves the base type for custom operators wrapped into
20-
* Completable via {@link Completable#create(CompletableConsumable)}.
20+
* Completable via {@link Completable#create(CompletableSource)}.
2121
*
2222
* @since 2.0
2323
*/
24-
public interface CompletableConsumable {
24+
public interface CompletableSource {
2525

26-
void subscribe(CompletableSubscriber cs);
26+
void subscribe(CompletableObserver cs);
2727
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright 2016 Netflix, Inc.
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;
15+
16+
import io.reactivex.functions.Function;
17+
18+
/**
19+
* Convenience interface and callback used by the compose operator to turn a Completable into another
20+
* Completable fluently.
21+
*/
22+
public interface CompletableTransformer extends Function<Completable, CompletableSource> {
23+
24+
}

src/main/java/io/reactivex/Single.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ public final Single<T> delay(final long time, final TimeUnit unit, final Schedul
633633
return new SingleDelay<T>(this, time, unit, scheduler);
634634
}
635635

636-
public final Single<T> delaySubscription(CompletableConsumable other) {
636+
public final Single<T> delaySubscription(CompletableSource other) {
637637
return new SingleDelayWithCompletable<T>(this, other);
638638
}
639639

src/main/java/io/reactivex/internal/disposables/EmptyDisposable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public static void error(Throwable e, Observer<?> s) {
4040
s.onError(e);
4141
}
4242

43-
public static void complete(CompletableSubscriber s) {
43+
public static void complete(CompletableObserver s) {
4444
s.onSubscribe(INSTANCE);
4545
s.onComplete();
4646
}
4747

48-
public static void error(Throwable e, CompletableSubscriber s) {
48+
public static void error(Throwable e, CompletableObserver s) {
4949
s.onSubscribe(INSTANCE);
5050
s.onError(e);
5151
}

src/main/java/io/reactivex/internal/operators/completable/CompletableAmbArray.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121

2222
public final class CompletableAmbArray extends Completable {
2323

24-
final CompletableConsumable[] sources;
24+
final CompletableSource[] sources;
2525

26-
public CompletableAmbArray(CompletableConsumable[] sources) {
26+
public CompletableAmbArray(CompletableSource[] sources) {
2727
this.sources = sources;
2828
}
2929

3030
@Override
31-
public void subscribeActual(final CompletableSubscriber s) {
31+
public void subscribeActual(final CompletableObserver s) {
3232
final CompositeDisposable set = new CompositeDisposable();
3333
s.onSubscribe(set);
3434

3535
final AtomicBoolean once = new AtomicBoolean();
3636

37-
CompletableSubscriber inner = new CompletableSubscriber() {
37+
CompletableObserver inner = new CompletableObserver() {
3838
@Override
3939
public void onComplete() {
4040
if (once.compareAndSet(false, true)) {
@@ -60,7 +60,7 @@ public void onSubscribe(Disposable d) {
6060

6161
};
6262

63-
for (CompletableConsumable c : sources) {
63+
for (CompletableSource c : sources) {
6464
if (set.isDisposed()) {
6565
return;
6666
}

src/main/java/io/reactivex/internal/operators/completable/CompletableAmbIterable.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222

2323
public final class CompletableAmbIterable extends Completable {
2424

25-
final Iterable<? extends CompletableConsumable> sources;
25+
final Iterable<? extends CompletableSource> sources;
2626

27-
public CompletableAmbIterable(Iterable<? extends CompletableConsumable> sources) {
27+
public CompletableAmbIterable(Iterable<? extends CompletableSource> sources) {
2828
this.sources = sources;
2929
}
3030

3131
@Override
32-
protected void subscribeActual(final CompletableSubscriber s) {
32+
protected void subscribeActual(final CompletableObserver s) {
3333
final CompositeDisposable set = new CompositeDisposable();
3434
s.onSubscribe(set);
3535

36-
Iterator<? extends CompletableConsumable> it;
36+
Iterator<? extends CompletableSource> it;
3737

3838
try {
3939
it = sources.iterator();
@@ -51,7 +51,7 @@ protected void subscribeActual(final CompletableSubscriber s) {
5151

5252
final AtomicBoolean once = new AtomicBoolean();
5353

54-
CompletableSubscriber inner = new CompletableSubscriber() {
54+
CompletableObserver inner = new CompletableObserver() {
5555
@Override
5656
public void onComplete() {
5757
if (once.compareAndSet(false, true)) {
@@ -109,7 +109,7 @@ public void onSubscribe(Disposable d) {
109109
return;
110110
}
111111

112-
CompletableConsumable c;
112+
CompletableSource c;
113113

114114
try {
115115
c = it.next();

src/main/java/io/reactivex/internal/operators/completable/CompletableAwait.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
public enum CompletableAwait {
2424
;
2525

26-
public static void await(CompletableConsumable cc) {
26+
public static void await(CompletableSource cc) {
2727
final CountDownLatch cdl = new CountDownLatch(1);
2828
final Throwable[] err = new Throwable[1];
2929

30-
cc.subscribe(new CompletableSubscriber() {
30+
cc.subscribe(new CompletableObserver() {
3131

3232
@Override
3333
public void onComplete() {
@@ -63,13 +63,13 @@ public void onSubscribe(Disposable d) {
6363
}
6464
}
6565

66-
public static boolean await(CompletableConsumable cc, long timeout, TimeUnit unit) {
66+
public static boolean await(CompletableSource cc, long timeout, TimeUnit unit) {
6767
Objects.requireNonNull(unit, "unit is null");
6868

6969
final CountDownLatch cdl = new CountDownLatch(1);
7070
final Throwable[] err = new Throwable[1];
7171

72-
cc.subscribe(new CompletableSubscriber() {
72+
cc.subscribe(new CompletableObserver() {
7373

7474
@Override
7575
public void onComplete() {
@@ -109,11 +109,11 @@ public void onSubscribe(Disposable d) {
109109
return b;
110110
}
111111

112-
public static Throwable get(CompletableConsumable cc) {
112+
public static Throwable get(CompletableSource cc) {
113113
final CountDownLatch cdl = new CountDownLatch(1);
114114
final Throwable[] err = new Throwable[1];
115115

116-
cc.subscribe(new CompletableSubscriber() {
116+
cc.subscribe(new CompletableObserver() {
117117

118118
@Override
119119
public void onComplete() {
@@ -144,13 +144,13 @@ public void onSubscribe(Disposable d) {
144144
return err[0];
145145
}
146146

147-
public static Throwable get(CompletableConsumable cc, long timeout, TimeUnit unit) {
147+
public static Throwable get(CompletableSource cc, long timeout, TimeUnit unit) {
148148
Objects.requireNonNull(unit, "unit is null");
149149

150150
final CountDownLatch cdl = new CountDownLatch(1);
151151
final Throwable[] err = new Throwable[1];
152152

153-
cc.subscribe(new CompletableSubscriber() {
153+
cc.subscribe(new CompletableObserver() {
154154

155155
@Override
156156
public void onComplete() {

0 commit comments

Comments
 (0)