File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
src/main/kotlin/me/proxer/app/util Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,21 @@ import io.reactivex.Flowable
44import io.reactivex.functions.Function
55import java.util.concurrent.TimeUnit
66
7+ /* *
8+ * Stolen and adjusted from here: https://stackoverflow.com/a/25292833/4279995
9+ */
710class RxRetryWithDelay (
8- private val maxRetries : Int ,
9- private val retryDelayMillis : Long
11+ private val maxRetries : Int ,
12+ private val retryDelayMillis : Long
1013) : Function<Flowable<out Throwable>, Flowable<*>> {
1114
1215 private var retryCount: Int = 0
1316
1417 override fun apply (attempts : Flowable <out Throwable >): Flowable <Any > = attempts
15- .flatMap { throwable ->
16- when {
17- ++ retryCount < maxRetries -> Flowable .timer(retryDelayMillis, TimeUnit .MILLISECONDS )
18- else -> Flowable .error(throwable)
19- }
18+ .flatMap { throwable ->
19+ when {
20+ ++ retryCount < maxRetries -> Flowable .timer(retryDelayMillis, TimeUnit .MILLISECONDS )
21+ else -> Flowable .error(throwable)
2022 }
23+ }
2124}
You can’t perform that action at this time.
0 commit comments