elizarov
01/01/2017, 11:03 PMsuspend fun <T> suspending(block: suspend () -> T): T = CoroutineIntrinsics.suspendCoroutineOrReturn { c ->
block.startCoroutine(completion = c)
CoroutineIntrinsics.SUSPENDED
}
Now, using suspending
helper function you can write:
suspend fun myFunction(args: Args): ReturnType = suspending {
\\ do whatever you want here -- invoke suspending functions at arbitrary points
}
Note, that the need to add suspending
will be removed in the future release.