<@U21LBQBU2> You can wrap any blocking api into su...
# coroutines
@bj0 You can wrap any blocking api into suspending (for coroutines) using
function from
like this:
Copy code
val btContext = newSingleThreadContext("Bluetooth") // a context with one thread for BT ops
suspend fun readFromBT() = run(btContext) { // convert blocking into non-blocking with run
    // do blocking read from bluetooth
Having defined it, you can use
from any coroutine and it is not going to block(!). For example, you can do it from a UI-bound coroutine:
Copy code
launch(UI) { // launch coroutine using UI dispatcher from kotlinx-coroutines-android
    while (true) {
        val data = readFromBT()
        displayData(data) // you are in UI thread here!!!
­čĹŹ 2