I am trying to make a coroutine from a method that I have.
to make things simple, let's say I have a class A that I try to connect() and it is connected only after class B that is inside A is connected.
So, I have this code for example, which offcourse doesn't work but it's just to show my use case-
class A {
    fun connect() {
        classB.connect()
        val isConnected = classB.isConnected
    }
}
class B {
    val isConnected: Boolean = false
    fun connect() {
        someObject.connect( SomeListenerInterface {
            override fun onSuccess() {
                isConnected = true
            }
        })
    }
}
I want to make the classB.connect() as a coroutine, and make it suspended, so only when it is done, the line of val isConnected = classB.isConnected would execute and the value would be set properly.
If I would use java and callbacks, I would just pass a callback to the classB.connect() method, and set the class A.isConnected value inside this callback.
is it possible with kotlin coroutines? Thanks