title: How to Exponential Backoff retry on kotlin coroutines
body: <p>I am using kotlin coroutines for network request using extension method to call class in retrofit like this</p>
  
  <pre><code>public suspend fun &lt;T : Any&gt; Call&lt;T&gt;.await(): T {
  
    return suspendCancellableCoroutine { continuation -&gt; 
  
      enqueue(object : Callback&lt;T&gt; {
  
          override fun onResponse(call: Call&lt;T&gt;?, response: Response&lt;T?&gt;) {
              if (response.isSuccessful) {
                  val body = response.body()
                  if (body == null) {
                      continuation.resumeWithException(
                              NullPointerException("Response body is null")
                      )
                  } else {
                      continuation.resume(body)
                  }
              } else {
                  continuation.resumeWithException(HttpException(response))
              }
          }
  
          override fun onFailure(call: Call&lt;T&gt;, t: Throwable) {
              // Don't bother with resuming the continuation if it is already cancelled.
              if (continuation.isCancelled) return
              continuation.resumeWithException(t)
          }
      })
  
        registerOnCompletion(continuation)
    }
  }
  </code></pre>
  
  <p>then from calling side i am using above method like this </p>
  
  <pre><code>private fun getArticles()  = launch(UI) {
  
      loading.value = true
      try {
          val networkResult = api.getArticle().await()
          articles.value =  networkResult
  
      }catch (e: Throwable){
          e.printStackTrace()
          message.value = e.message
  
      }finally {
          loading.value = false
      }
  
  }
  </code></pre>
  
  <p>i  want to exponential retry this api call in some case i.e (IOException) how can i achieve it ??</p>