Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.x: Add Completable.doOnCompleted and deprecate Completable.doOnComplete #3701

Merged
merged 1 commit into from
Feb 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1.x: alias Observable.doOnCompleted to match Completable and 2x
Closes #3700.
  • Loading branch information
zach-klippenstein committed Feb 12, 2016
commit 82f5da59fedbd3cadace2f16787c2f81d3910e12
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