|
52 | 52 | import rx.operators.OperationOnErrorResumeNextViaObservable;
|
53 | 53 | import rx.operators.OperationOnErrorReturn;
|
54 | 54 | import rx.operators.OperationOnExceptionResumeNextViaObservable;
|
| 55 | +import rx.operators.OperationRetry; |
55 | 56 | import rx.operators.OperationSample;
|
56 | 57 | import rx.operators.OperationScan;
|
57 | 58 | import rx.operators.OperationSkip;
|
@@ -1891,29 +1892,6 @@ public static <T> Observable<T> from(Future<? extends T> future, long timeout, T
|
1891 | 1892 | return create(OperationToObservableFuture.toObservableFuture(future, timeout, unit));
|
1892 | 1893 | }
|
1893 | 1894 |
|
1894 |
| - /** |
1895 |
| - * <p> |
1896 |
| - * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png"> |
1897 |
| - * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the |
1898 |
| - * new Observable will be the result of the function applied to the first item emitted by {@code w0} and the first item emitted by {@code w1}; the second item emitted by |
1899 |
| - * the new Observable will be the result of the function applied to the second item emitted by {@code w0} and the second item emitted by {@code w1}; and so forth. |
1900 |
| - * <p> |
1901 |
| - * The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations |
1902 |
| - * of the source Observable that emits the fewest items. |
1903 |
| - * |
1904 |
| - * @param o1 |
1905 |
| - * one source Observable |
1906 |
| - * @param o2 |
1907 |
| - * another source Observable |
1908 |
| - * @param zipFunction |
1909 |
| - * a function that, when applied to an item emitted by each of the source |
1910 |
| - * Observables, results in an item that will be emitted by the resulting Observable |
1911 |
| - * @return an Observable that emits the zipped results |
1912 |
| - */ |
1913 |
| - public static <T1, T2, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Func2<? super T1, ? super T2, ? extends R> zipFunction) { |
1914 |
| - return create(OperationZip.zip(o1, o2, zipFunction)); |
1915 |
| - } |
1916 |
| - |
1917 | 1895 | /**
|
1918 | 1896 | * Returns an Observable that emits Boolean values that indicate whether the pairs of items
|
1919 | 1897 | * emitted by two source Observables are equal.
|
@@ -1960,6 +1938,31 @@ public static <T> Observable<Boolean> sequenceEqual(Observable<? extends T> firs
|
1960 | 1938 | return zip(first, second, equality);
|
1961 | 1939 | }
|
1962 | 1940 |
|
| 1941 | + /** |
| 1942 | + * Returns an Observable that emits the results of a function of your choosing applied to |
| 1943 | + * combinations of two items emitted, in sequence, by two other Observables. |
| 1944 | + * <p> |
| 1945 | + * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png"> |
| 1946 | + * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the |
| 1947 | + * new Observable will be the result of the function applied to the first item emitted by {@code w0} and the first item emitted by {@code w1}; the second item emitted by |
| 1948 | + * the new Observable will be the result of the function applied to the second item emitted by {@code w0} and the second item emitted by {@code w1}; and so forth. |
| 1949 | + * <p> |
| 1950 | + * The resulting {@code Observable<R>} returned from {@code zip} will invoke {@link Observer#onNext onNext} as many times as the number of {@code onNext} invocations |
| 1951 | + * of the source Observable that emits the fewest items. |
| 1952 | + * |
| 1953 | + * @param o1 |
| 1954 | + * one source Observable |
| 1955 | + * @param o2 |
| 1956 | + * another source Observable |
| 1957 | + * @param zipFunction |
| 1958 | + * a function that, when applied to an item emitted by each of the source |
| 1959 | + * Observables, results in an item that will be emitted by the resulting Observable |
| 1960 | + * @return an Observable that emits the zipped results |
| 1961 | + */ |
| 1962 | + public static <T1, T2, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Func2<? super T1, ? super T2, ? extends R> zipFunction) { |
| 1963 | + return create(OperationZip.zip(o1, o2, zipFunction)); |
| 1964 | + } |
| 1965 | + |
1963 | 1966 | /**
|
1964 | 1967 | * Returns an Observable that emits the results of a function of your choosing applied to
|
1965 | 1968 | * combinations of three items emitted, in sequence, by three other Observables.
|
@@ -2021,7 +2024,7 @@ public static <T1, T2, T3, T4, R> Observable<R> zip(Observable<? extends T1> o1,
|
2021 | 2024 |
|
2022 | 2025 | /**
|
2023 | 2026 | * Returns an Observable that emits the results of a function of your choosing applied to
|
2024 |
| - * combinations of four items emitted, in sequence, by four other Observables. |
| 2027 | + * combinations of five items emitted, in sequence, by five other Observables. |
2025 | 2028 | * <p>
|
2026 | 2029 | * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
|
2027 | 2030 | * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
|
@@ -2054,7 +2057,7 @@ public static <T1, T2, T3, T4, T5, R> Observable<R> zip(Observable<? extends T1>
|
2054 | 2057 |
|
2055 | 2058 | /**
|
2056 | 2059 | * Returns an Observable that emits the results of a function of your choosing applied to
|
2057 |
| - * combinations of four items emitted, in sequence, by four other Observables. |
| 2060 | + * combinations of six items emitted, in sequence, by six other Observables. |
2058 | 2061 | * <p>
|
2059 | 2062 | * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
|
2060 | 2063 | * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
|
@@ -2090,7 +2093,7 @@ public static <T1, T2, T3, T4, T5, T6, R> Observable<R> zip(Observable<? extends
|
2090 | 2093 |
|
2091 | 2094 | /**
|
2092 | 2095 | * Returns an Observable that emits the results of a function of your choosing applied to
|
2093 |
| - * combinations of four items emitted, in sequence, by four other Observables. |
| 2096 | + * combinations of seven items emitted, in sequence, by seven other Observables. |
2094 | 2097 | * <p>
|
2095 | 2098 | * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
|
2096 | 2099 | * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
|
@@ -2128,7 +2131,7 @@ public static <T1, T2, T3, T4, T5, T6, T7, R> Observable<R> zip(Observable<? ext
|
2128 | 2131 |
|
2129 | 2132 | /**
|
2130 | 2133 | * Returns an Observable that emits the results of a function of your choosing applied to
|
2131 |
| - * combinations of four items emitted, in sequence, by four other Observables. |
| 2134 | + * combinations of eight items emitted, in sequence, by eight other Observables. |
2132 | 2135 | * <p>
|
2133 | 2136 | * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
|
2134 | 2137 | * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
|
@@ -2168,7 +2171,7 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, R> Observable<R> zip(Observable<?
|
2168 | 2171 |
|
2169 | 2172 | /**
|
2170 | 2173 | * Returns an Observable that emits the results of a function of your choosing applied to
|
2171 |
| - * combinations of four items emitted, in sequence, by four other Observables. |
| 2174 | + * combinations of nine items emitted, in sequence, by nine other Observables. |
2172 | 2175 | * <p>
|
2173 | 2176 | * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/zip.png">
|
2174 | 2177 | * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
|
@@ -2680,7 +2683,8 @@ public Observable<Observable<T>> window(long timespan, long timeshift, TimeUnit
|
2680 | 2683 |
|
2681 | 2684 | /**
|
2682 | 2685 | * Returns an Observable that emits the results of a function of your choosing applied to
|
2683 |
| - * combinations of four items emitted, in sequence, by four other Observables. |
| 2686 | + * combinations of N items emitted, in sequence, by N other Observables as provided by an Iterable. |
| 2687 | + * |
2684 | 2688 | * <p> {@code zip} applies this function in strict sequence, so the first item emitted by the
|
2685 | 2689 | * new Observable will be the result of the function applied to the first item emitted by
|
2686 | 2690 | * all of the Observalbes; the second item emitted by the new Observable will be the result of
|
@@ -2727,7 +2731,7 @@ public Observable<R> call(List<? extends Observable<?>> wsList) {
|
2727 | 2731 | * Observables, results in an item that will be emitted by the resulting Observable
|
2728 | 2732 | * @return an Observable that emits the zipped results
|
2729 | 2733 | */
|
2730 |
| - public static <R> Observable<R> zip(Collection<? extends Observable<?>> ws, FuncN<? extends R> zipFunction) { |
| 2734 | + public static <R> Observable<R> zip(Iterable<? extends Observable<?>> ws, FuncN<? extends R> zipFunction) { |
2731 | 2735 | return create(OperationZip.zip(ws, zipFunction));
|
2732 | 2736 | }
|
2733 | 2737 |
|
@@ -3125,6 +3129,42 @@ public static Observable<Double> averageDoubles(Observable<Double> source) {
|
3125 | 3129 | public ConnectableObservable<T> replay() {
|
3126 | 3130 | return OperationMulticast.multicast(this, ReplaySubject.<T> create());
|
3127 | 3131 | }
|
| 3132 | + |
| 3133 | + /** |
| 3134 | + * Retry subscription to origin Observable upto given retry count. |
| 3135 | + * <p> |
| 3136 | + * If {@link Observer#onError} is invoked the source Observable will be re-subscribed to as many times as defined by retryCount. |
| 3137 | + * <p> |
| 3138 | + * Any {@link Observer#onNext} calls received on each attempt will be emitted and concatenated together. |
| 3139 | + * <p> |
| 3140 | + * For example, if an Observable fails on first time but emits [1, 2] then succeeds the second time and |
| 3141 | + * emits [1, 2, 3, 4, 5] then the complete output would be [1, 2, 1, 2, 3, 4, 5, onCompleted]. |
| 3142 | + * |
| 3143 | + * @param retryCount |
| 3144 | + * Number of retry attempts before failing. |
| 3145 | + * @return Observable with retry logic. |
| 3146 | + */ |
| 3147 | + public Observable<T> retry(int retryCount) { |
| 3148 | + return create(OperationRetry.retry(this, retryCount)); |
| 3149 | + } |
| 3150 | + |
| 3151 | + /** |
| 3152 | + * Retry subscription to origin Observable whenever onError is called (infinite retry count). |
| 3153 | + * <p> |
| 3154 | + * If {@link Observer#onError} is invoked the source Observable will be re-subscribed to. |
| 3155 | + * <p> |
| 3156 | + * Any {@link Observer#onNext} calls received on each attempt will be emitted and concatenated together. |
| 3157 | + * <p> |
| 3158 | + * For example, if an Observable fails on first time but emits [1, 2] then succeeds the second time and |
| 3159 | + * emits [1, 2, 3, 4, 5] then the complete output would be [1, 2, 1, 2, 3, 4, 5, onCompleted]. |
| 3160 | + * |
| 3161 | + * @param retryCount |
| 3162 | + * Number of retry attempts before failing. |
| 3163 | + * @return Observable with retry logic. |
| 3164 | + */ |
| 3165 | + public Observable<T> retry() { |
| 3166 | + return create(OperationRetry.retry(this)); |
| 3167 | + } |
3128 | 3168 |
|
3129 | 3169 | /**
|
3130 | 3170 | * This method has similar behavior to {@link #replay} except that this auto-subscribes to
|
|
0 commit comments