createCoroutine

Common
JVM
JS
Native
1.3
fun <T> (suspend () -> T).createCoroutine(
    completion: Continuation<T>
): Continuation<Unit>

(source)

Creates a coroutine without a receiver and with result type T. This function creates a new, fresh instance of suspendable computation every time it is invoked.

To start executing the created coroutine, invoke resume(Unit) on the returned Continuation instance. The completion continuation is invoked when the coroutine completes with a result or an exception. Subsequent invocation of any resume function on the resulting continuation will produce an IllegalStateException.

Common
JVM
JS
Native
1.3
fun <R, T> (suspend R.() -> T).createCoroutine(
    receiver: R,
    completion: Continuation<T>
): Continuation<Unit>

(source)

Creates a coroutine with receiver type R and result type T. This function creates a new, fresh instance of suspendable computation every time it is invoked.

To start executing the created coroutine, invoke resume(Unit) on the returned Continuation instance. The completion continuation is invoked when the coroutine completes with a result or an exception. Subsequent invocation of any resume function on the resulting continuation will produce an IllegalStateException.