daw man this coulda been really neat: ``` import c...
# coroutines
g
daw man this coulda been really neat:
Copy code
import com.google.guava.EventBus

suspend inline fun <reified T: Event, R> EventBus.suspendUntil(eventPostingBlock: () -> R): R {
    val finished = RendezvousChannel<T>()
    val subscription = @Subscribe fun(event: T) = launch(CommonPool) { finished.send(event) }

    register(subscription)
    var result = try {
        eventPostingBlock.invoke()
    }
    finally {
        unregister(subscription)
    }

    return result
}
compiler error on
fun
"inline local functions are not currently supported". I'm playing serious games with the type system to declare a local function with a parameter of type
T
, so i suspect the kotlin compiler would require a nightmare of code to support that, but still, the syntax is pretty slick