Skip to content

Commit 664e766

Browse files
authored
Replace usages of deprecated sendBlocking with trySendBlocking (#138)
1 parent 7904013 commit 664e766

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

core/src/androidMain/kotlin/Scanner.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import android.util.Log
1010
import com.benasher44.uuid.Uuid
1111
import kotlinx.coroutines.cancel
1212
import kotlinx.coroutines.channels.awaitClose
13-
import kotlinx.coroutines.channels.sendBlocking
13+
import kotlinx.coroutines.channels.onFailure
14+
import kotlinx.coroutines.channels.trySendBlocking
1415
import kotlinx.coroutines.flow.Flow
1516
import kotlinx.coroutines.flow.callbackFlow
1617

@@ -30,17 +31,16 @@ public class AndroidScanner internal constructor(private val filterServices: Lis
3031

3132
val callback = object : ScanCallback() {
3233
override fun onScanResult(callbackType: Int, result: ScanResult) {
33-
runCatching {
34-
sendBlocking(Advertisement(result))
35-
}.onFailure {
36-
Log.w(TAG, "Unable to deliver scan result due to failure in flow or premature closing.")
37-
}
34+
trySendBlocking(Advertisement(result))
35+
.onFailure {
36+
Log.w(TAG, "Unable to deliver scan result due to failure in flow or premature closing.")
37+
}
3838
}
3939

4040
override fun onBatchScanResults(results: MutableList<ScanResult>) {
4141
runCatching {
4242
results.forEach {
43-
sendBlocking(Advertisement(it))
43+
trySendBlocking(Advertisement(it)).getOrThrow()
4444
}
4545
}.onFailure {
4646
Log.w(TAG, "Unable to deliver batch scan results due to failure in flow or premature closing.")

0 commit comments

Comments
 (0)