Skip to content

Commit

Permalink
1.x: alias Observable.doOnCompleted to match Completable and 2x
Browse files Browse the repository at this point in the history
  • Loading branch information
zach-klippenstein committed Feb 12, 2016
1 parent 9f49624 commit 82f5da5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
15 changes: 13 additions & 2 deletions src/main/java/rx/Completable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1222,9 +1222,20 @@ public void onSubscribe(Subscription d) {
* @param onComplete the callback to call when this emits an onComplete event
* @return the new Completable instance
* @throws NullPointerException if onComplete is null
* @deprecated Use {@link #doOnCompleted(Action0)} instead.
*/
public final Completable doOnComplete(Action0 onComplete) {
return doOnLifecycle(Actions.empty(), Actions.empty(), onComplete, Actions.empty(), Actions.empty());
@Deprecated public final Completable doOnComplete(Action0 onComplete) {
return doOnCompleted(onComplete);
}

/**
* Returns a Completable which calls the given onCompleted callback if this Completable completes.
* @param onCompleted the callback to call when this emits an onComplete event
* @return the new Completable instance
* @throws NullPointerException if onComplete is null
*/
public final Completable doOnCompleted(Action0 onCompleted) {
return doOnLifecycle(Actions.empty(), Actions.empty(), onCompleted, Actions.empty(), Actions.empty());
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/rx/CompletableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1673,10 +1673,10 @@ public void onCompleted() {
}

@Test(timeout = 1000)
public void doOnCompleteNormal() {
public void doOnCompletedNormal() {
final AtomicInteger calls = new AtomicInteger();

Completable c = normal.completable.doOnComplete(new Action0() {
Completable c = normal.completable.doOnCompleted(new Action0() {
@Override
public void call() {
calls.getAndIncrement();
Expand All @@ -1689,10 +1689,10 @@ public void call() {
}

@Test(timeout = 1000)
public void doOnCompleteError() {
public void doOnCompletedError() {
final AtomicInteger calls = new AtomicInteger();

Completable c = error.completable.doOnComplete(new Action0() {
Completable c = error.completable.doOnCompleted(new Action0() {
@Override
public void call() {
calls.getAndIncrement();
Expand All @@ -1710,13 +1710,13 @@ public void call() {
}

@Test(expected = NullPointerException.class)
public void doOnCompleteNull() {
normal.completable.doOnComplete(null);
public void doOnCompletedNull() {
normal.completable.doOnCompleted(null);
}

@Test(timeout = 1000, expected = TestException.class)
public void doOnCompleteThrows() {
Completable c = normal.completable.doOnComplete(new Action0() {
public void doOnCompletedThrows() {
Completable c = normal.completable.doOnCompleted(new Action0() {
@Override
public void call() { throw new TestException(); }
});
Expand Down Expand Up @@ -2469,7 +2469,7 @@ public void subscribe() throws InterruptedException {

Completable c = normal.completable
.delay(100, TimeUnit.MILLISECONDS)
.doOnComplete(new Action0() {
.doOnCompleted(new Action0() {
@Override
public void call() {
complete.set(true);
Expand All @@ -2489,7 +2489,7 @@ public void subscribeDispose() throws InterruptedException {

Completable c = normal.completable
.delay(200, TimeUnit.MILLISECONDS)
.doOnComplete(new Action0() {
.doOnCompleted(new Action0() {
@Override
public void call() {
complete.set(true);
Expand Down

0 comments on commit 82f5da5

Please sign in to comment.