Skip to content

Commit

Permalink
catch offer exceptions. See Kotlin/kotlinx.coroutines#974
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Feb 20, 2020
1 parent 533a163 commit 45f417e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import kotlinx.coroutines.flow.*

private class ChannelCallback<T>(val channel: Channel<Response<T>>) : ApolloCall.Callback<T>() {

@ExperimentalCoroutinesApi
override fun onResponse(response: Response<T>) {
if (!channel.isClosedForSend) {
runCatching {
channel.offer(response)
}
}
Expand Down Expand Up @@ -196,7 +195,9 @@ fun <T> ApolloSubscriptionCall<T>.toChannel(capacity: Int = Channel.UNLIMITED):
}

override fun onResponse(response: Response<T>) {
channel.offer(response)
runCatching {
channel.offer(response)
}
}

override fun onFailure(e: ApolloException) {
Expand Down

0 comments on commit 45f417e

Please sign in to comment.