Commit 609f9bda authored by Yusuke Iwaki's avatar Yusuke Iwaki

rename variable name and add comment.

parent d6108418
...@@ -10,7 +10,9 @@ import rx.functions.Func1; ...@@ -10,7 +10,9 @@ import rx.functions.Func1;
public class RxHelper { public class RxHelper {
public static Func1<Observable<? extends Throwable>, Observable<?>> exponentialBackoff( public static Func1<Observable<? extends Throwable>, Observable<?>> exponentialBackoff(
int maxRetryCount, long base, TimeUnit unit) { int maxRetryCount, long base, TimeUnit unit) {
return errors -> errors
// ref: https://github.com/ReactiveX/RxJava/blob/a8ba158839b67246a742b6f1531995ffd7545c08/src/main/java/io/reactivex/Observable.java#L9601
return attempts -> attempts
.zipWith(Observable.range(0, maxRetryCount), (error, retryCount) -> retryCount) .zipWith(Observable.range(0, maxRetryCount), (error, retryCount) -> retryCount)
.flatMap(retryCount -> Observable.timer(base * (long) Math.pow(2, retryCount), unit)); .flatMap(retryCount -> Observable.timer(base * (long) Math.pow(2, retryCount), unit));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment