https://kotlinlang.org logo
k

kirillrakhman

04/13/2017, 9:44 AM
interestingly enough, you can write the universal callback wrapping function with coroutines
Copy code
suspend fun <T> wrapCallback(function: ((T) -> Any) -> Any): T = suspendCoroutine { c ->
    function(c::resume)
}
but it requires that the callback function accepts kotlin's function types which most of the time it doesn't
👍 1