|
21 | 21 | import rx.annotations.Experimental;
|
22 | 22 | import rx.exceptions.Exceptions;
|
23 | 23 | import rx.exceptions.OnErrorNotImplementedException;
|
| 24 | +import rx.functions.Action0; |
24 | 25 | import rx.functions.Action1;
|
25 | 26 | import rx.functions.Func1;
|
26 | 27 | import rx.functions.Func2;
|
|
33 | 34 | import rx.functions.Func9;
|
34 | 35 | import rx.internal.operators.OnSubscribeToObservableFuture;
|
35 | 36 | import rx.internal.operators.OperatorDoOnEach;
|
| 37 | +import rx.internal.operators.OperatorFinally; |
36 | 38 | import rx.internal.operators.OperatorMap;
|
37 | 39 | import rx.internal.operators.OperatorObserveOn;
|
38 | 40 | import rx.internal.operators.OperatorOnErrorReturn;
|
@@ -1898,4 +1900,25 @@ public void onNext(T t) {
|
1898 | 1900 |
|
1899 | 1901 | return lift(new OperatorDoOnEach<T>(observer));
|
1900 | 1902 | }
|
| 1903 | + |
| 1904 | + /** |
| 1905 | + * Registers an {@link Action0} to be called when this {@link Single} invokes either |
| 1906 | + * {@link SingleSubscriber#onSuccess(Object)} onSuccess} or {@link SingleSubscriber#onError onError}. |
| 1907 | + * <p> |
| 1908 | + * <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/finallyDo.png" alt=""> |
| 1909 | + * <dl> |
| 1910 | + * <dt><b>Scheduler:</b></dt> |
| 1911 | + * <dd>{@code finallyDo} does not operate by default on a particular {@link Scheduler}.</dd> |
| 1912 | + * </dl> |
| 1913 | + * |
| 1914 | + * @param action |
| 1915 | + * an {@link Action0} to be invoked when the source {@link Single} finishes. |
| 1916 | + * @return a {@link Single} that emits the same item or error as the source {@link Single}, then invokes the |
| 1917 | + * {@link Action0} |
| 1918 | + * @see <a href="http://reactivex.io/documentation/operators/do.html">ReactiveX operators documentation: Do</a> |
| 1919 | + */ |
| 1920 | + @Experimental |
| 1921 | + public final Single<T> finallyDo(Action0 action) { |
| 1922 | + return lift(new OperatorFinally<T>(action)); |
| 1923 | + } |
1901 | 1924 | }
|
0 commit comments