package chat.rocket.android.helper;

import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.functions.Func1;

/**
 * Rx operator and so on.
 */
public class RxHelper {
  public static Func1<Observable<? extends Throwable>, Observable<?>> exponentialBackoff(
      int maxRetryCount, long base, TimeUnit unit) {
    return errors -> errors
        .zipWith(Observable.range(0, maxRetryCount), (error, retryCount) -> retryCount)
        .flatMap(retryCount -> Observable.timer(base * (long) Math.pow(2, retryCount), unit));
  }
}

@@ -323,34 +323,182 @@
 ) %7B%0A
+%0A
     
-return errors -%3E error
+// ref: https://github.com/ReactiveX/RxJava/blob/a8ba158839b67246a742b6f1531995ffd7545c08/src/main/java/io/reactivex/Observable.java#L9601%0A    return attempts -%3E attempt
 s%0A  

rename variable name and add comment.