Skip to content

Commit 0689479

Browse files
doOnNext, doOnCompleted, doOnError, doOnEach
1 parent add6c29 commit 0689479

File tree

1 file changed

+25
-62
lines changed

1 file changed

+25
-62
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ public static <T> Observable<T> from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T
10541054
public static <T> Observable<T> from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9, T t10) {
10551055
return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10));
10561056
}
1057-
1057+
10581058
/**
10591059
* Generates an Observable that emits a sequence of Integers within a
10601060
* specified range.
@@ -6571,36 +6571,6 @@ public Observable<T> doOnEach(Observer<? super T> observer) {
65716571
return create(OperationDoOnEach.doOnEach(this, observer));
65726572
}
65736573

6574-
/**
6575-
* Invokes an action for each item emitted by an Observable.
6576-
* <p>
6577-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/doOnEach.png">
6578-
*
6579-
* @param onNext the action to invoke for each item emitted by the source
6580-
* Observable
6581-
* @return the source Observable with the side-effecting behavior applied
6582-
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#dooneach">RxJava Wiki: doOnEach()</a>
6583-
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229804.aspx">MSDN: Observable.Do</a>
6584-
*/
6585-
public Observable<T> doOnEach(final Action1<? super T> onNext) {
6586-
Observer<T> observer = new Observer<T>() {
6587-
@Override
6588-
public void onCompleted() {}
6589-
6590-
@Override
6591-
public void onError(Throwable e) {}
6592-
6593-
@Override
6594-
public void onNext(T args) {
6595-
onNext.call(args);
6596-
}
6597-
6598-
};
6599-
6600-
6601-
return create(OperationDoOnEach.doOnEach(this, observer));
6602-
}
6603-
66046574
/**
66056575
* Invokes an action if the source Observable calls <code>onError</code>.
66066576
* <p>
@@ -6661,71 +6631,64 @@ public void onNext(T args) { }
66616631

66626632
return create(OperationDoOnEach.doOnEach(this, observer));
66636633
}
6664-
6634+
6635+
66656636
/**
6666-
* Invokes an action for each item emitted by an Observable.
6637+
* Invokes an action when the source Observable calls
6638+
* <code>onNext</code>.
66676639
* <p>
6668-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/doOnEach.e.png">
6640+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/doOnCompleted.png">
66696641
*
6670-
* @param onNext the action to invoke for each item emitted by the
6671-
* Observable
6672-
* @param onError the action to invoke when the source Observable calls
6673-
* <code>onError</code>
6642+
* @param onCompleted the action to invoke when the source Observable calls
6643+
* <code>onCompleted</code>
66746644
* @return the source Observable with the side-effecting behavior applied
6675-
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#dooneach">RxJava Wiki: doOnEach()</a>
6676-
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229539.aspx">MSDN: Observable.Do</a>
6645+
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#dooneach">RxJava Wiki: doOnNext()</a>
6646+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229804.aspx">MSDN: Observable.Do</a>
66776647
*/
6678-
public Observable<T> doOnEach(final Action1<? super T> onNext, final Action1<Throwable> onError) {
6648+
public Observable<T> doOnNext(final Action1<T> onNext) {
66796649
Observer<T> observer = new Observer<T>() {
66806650
@Override
6681-
public void onCompleted() {}
6651+
public void onCompleted() { }
66826652

66836653
@Override
6684-
public void onError(Throwable e) {
6685-
onError.call(e);
6686-
}
6654+
public void onError(Throwable e) { }
66876655

66886656
@Override
6689-
public void onNext(T args) {
6657+
public void onNext(T args) {
66906658
onNext.call(args);
66916659
}
66926660

66936661
};
66946662

6695-
66966663
return create(OperationDoOnEach.doOnEach(this, observer));
66976664
}
6698-
6665+
66996666
/**
6700-
* Invokes an action for each item emitted by an Observable.
6667+
* Invokes an action for each item emitted by the Observable.
67016668
* <p>
6702-
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/doOnEach.ce.png">
6669+
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/doOnEach.png">
67036670
*
6704-
* @param onNext the action to invoke for each item emitted by the
6705-
* Observable
6706-
* @param onError the action to invoke when the source Observable calls
6707-
* <code>onError</code>
6708-
* @param onCompleted the action to invoke when the source Observable calls
6709-
* <code>onCompleted</code>
6671+
* @param observer the action to invoke for each item emitted by the source
6672+
* Observable
67106673
* @return the source Observable with the side-effecting behavior applied
67116674
* @see <a href="https://github.com/Netflix/RxJava/wiki/Observable-Utility-Operators#dooneach">RxJava Wiki: doOnEach()</a>
6712-
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229830.aspx">MSDN: Observable.Do</a>
6675+
* @see <a href="http://msdn.microsoft.com/en-us/library/hh229307.aspx">MSDN: Observable.Do</a>
67136676
*/
6714-
public Observable<T> doOnEach(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onCompleted) {
6677+
public Observable<T> doOnEach(final Action1<Notification<T>> onNotification) {
67156678
Observer<T> observer = new Observer<T>() {
67166679
@Override
67176680
public void onCompleted() {
6718-
onCompleted.call();
6681+
onNotification.call(new Notification<T>());
67196682
}
67206683

67216684
@Override
67226685
public void onError(Throwable e) {
6723-
onError.call(e);
6686+
onNotification.call(new Notification<T>(e));
67246687
}
67256688

67266689
@Override
6727-
public void onNext(T args) {
6728-
onNext.call(args);
6690+
public void onNext(T v) {
6691+
onNotification.call(new Notification<T>(v));
67296692
}
67306693

67316694
};

0 commit comments

Comments
 (0)