Skip to content

Commit

Permalink
tryAwait方法参数默认null
Browse files Browse the repository at this point in the history
  • Loading branch information
liujingxing committed Oct 26, 2021
1 parent a5ebb50 commit b1383d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rxhttp/src/main/java/rxhttp/AwaitTransform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ suspend fun <T> Deferred<T>.awaitResult(onSuccess: (value: T) -> Unit): Result<T
awaitResult().onSuccess(onSuccess)

//return null when an error occurs.
suspend fun <T> Deferred<T>.tryAwait(onCatch: ((Throwable) -> Unit)?): T? =
suspend fun <T> Deferred<T>.tryAwait(onCatch: ((Throwable) -> Unit)? = null): T? =
try {
await()
} catch (e: Throwable) {
Expand All @@ -423,7 +423,7 @@ suspend fun <T> Deferred<T>.tryAwait(onCatch: ((Throwable) -> Unit)?): T? =
}

//return null when an error occurs.
suspend fun <T> Await<T>.tryAwait(onCatch: ((Throwable) -> Unit)?): T? =
suspend fun <T> Await<T>.tryAwait(onCatch: ((Throwable) -> Unit)? = null): T? =
try {
await()
} catch (e: Throwable) {
Expand Down

0 comments on commit b1383d6

Please sign in to comment.