Skip to content

//NetworkResponseAdapter/com.haroldadmin.cnradapter/executeWithRetry

executeWithRetry

[jvm]\ inline suspend fun <T : Any, U : Any> executeWithRetry(times: Int = 10, initialDelay: Long = 100, maxDelay: Long = 1000, factor: Double = 2.0, block: suspend () -> NetworkResponse<T, U>): NetworkResponse<T, U>

Retries the given block for the specified number of times in the case of NetworkResponse.NetworkError

Return

The NetworkResponse value whether it be successful or failed after retrying

Parameters

jvm

T The success body type of NetworkResponse
U The error body type of NetworkResponse
times The number of times this request should be retried
initialDelay The initial amount of time to wait before retrying
maxDelay The max amount of time to wait before retrying
factor Multiply current delay time with this on each retry
block The suspending function to be retried