We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6d339de commit 505ba3cCopy full SHA for 505ba3c
firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/extensions.kt
@@ -6,8 +6,6 @@ import kotlinx.coroutines.channels.SendChannel
6
7
//workaround for https://github.com/Kotlin/kotlinx.coroutines/issues/974
8
@ExperimentalCoroutinesApi
9
-fun <E> SendChannel<E>.safeOffer(element: E) = try {
10
- !isClosedForSend && offer(element)
11
-} catch (e : ClosedSendChannelException) {
12
- false
+fun <E> SendChannel<E>.safeOffer(element: E): Boolean {
+ return runCatching { !isClosedForSend && offer(element) }.getOrDefault(false)
13
}
0 commit comments