Skip to content

Commit 82f5da5

Browse files
1.x: alias Observable.doOnCompleted to match Completable and 2x
Closes #3700.
1 parent 9f49624 commit 82f5da5

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

src/main/java/rx/Completable.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,9 +1222,20 @@ public void onSubscribe(Subscription d) {
12221222
* @param onComplete the callback to call when this emits an onComplete event
12231223
* @return the new Completable instance
12241224
* @throws NullPointerException if onComplete is null
1225+
* @deprecated Use {@link #doOnCompleted(Action0)} instead.
12251226
*/
1226-
public final Completable doOnComplete(Action0 onComplete) {
1227-
return doOnLifecycle(Actions.empty(), Actions.empty(), onComplete, Actions.empty(), Actions.empty());
1227+
@Deprecated public final Completable doOnComplete(Action0 onComplete) {
1228+
return doOnCompleted(onComplete);
1229+
}
1230+
1231+
/**
1232+
* Returns a Completable which calls the given onCompleted callback if this Completable completes.
1233+
* @param onCompleted the callback to call when this emits an onComplete event
1234+
* @return the new Completable instance
1235+
* @throws NullPointerException if onComplete is null
1236+
*/
1237+
public final Completable doOnCompleted(Action0 onCompleted) {
1238+
return doOnLifecycle(Actions.empty(), Actions.empty(), onCompleted, Actions.empty(), Actions.empty());
12281239
}
12291240

12301241
/**

src/test/java/rx/CompletableTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,10 +1673,10 @@ public void onCompleted() {
16731673
}
16741674

16751675
@Test(timeout = 1000)
1676-
public void doOnCompleteNormal() {
1676+
public void doOnCompletedNormal() {
16771677
final AtomicInteger calls = new AtomicInteger();
16781678

1679-
Completable c = normal.completable.doOnComplete(new Action0() {
1679+
Completable c = normal.completable.doOnCompleted(new Action0() {
16801680
@Override
16811681
public void call() {
16821682
calls.getAndIncrement();
@@ -1689,10 +1689,10 @@ public void call() {
16891689
}
16901690

16911691
@Test(timeout = 1000)
1692-
public void doOnCompleteError() {
1692+
public void doOnCompletedError() {
16931693
final AtomicInteger calls = new AtomicInteger();
16941694

1695-
Completable c = error.completable.doOnComplete(new Action0() {
1695+
Completable c = error.completable.doOnCompleted(new Action0() {
16961696
@Override
16971697
public void call() {
16981698
calls.getAndIncrement();
@@ -1710,13 +1710,13 @@ public void call() {
17101710
}
17111711

17121712
@Test(expected = NullPointerException.class)
1713-
public void doOnCompleteNull() {
1714-
normal.completable.doOnComplete(null);
1713+
public void doOnCompletedNull() {
1714+
normal.completable.doOnCompleted(null);
17151715
}
17161716

17171717
@Test(timeout = 1000, expected = TestException.class)
1718-
public void doOnCompleteThrows() {
1719-
Completable c = normal.completable.doOnComplete(new Action0() {
1718+
public void doOnCompletedThrows() {
1719+
Completable c = normal.completable.doOnCompleted(new Action0() {
17201720
@Override
17211721
public void call() { throw new TestException(); }
17221722
});
@@ -2469,7 +2469,7 @@ public void subscribe() throws InterruptedException {
24692469

24702470
Completable c = normal.completable
24712471
.delay(100, TimeUnit.MILLISECONDS)
2472-
.doOnComplete(new Action0() {
2472+
.doOnCompleted(new Action0() {
24732473
@Override
24742474
public void call() {
24752475
complete.set(true);
@@ -2489,7 +2489,7 @@ public void subscribeDispose() throws InterruptedException {
24892489

24902490
Completable c = normal.completable
24912491
.delay(200, TimeUnit.MILLISECONDS)
2492-
.doOnComplete(new Action0() {
2492+
.doOnCompleted(new Action0() {
24932493
@Override
24942494
public void call() {
24952495
complete.set(true);

0 commit comments

Comments
 (0)