W3cubDocs

/Kotlin

startCoroutine

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
fun <T> (suspend () -> T).startCoroutine(
    completion: Continuation<T>)

Starts a coroutine without a receiver and with result type T. This function creates and starts a new, fresh instance of suspendable computation every time it is invoked. The completion continuation is invoked when the coroutine completes with a result or an exception.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
fun <R, T> (suspend R.() -> T).startCoroutine(
    receiver: R, 
    completion: Continuation<T>)

Starts a coroutine with receiver type R and result type T. This function creates and starts a new, fresh instance of suspendable computation every time it is invoked. The completion continuation is invoked when the coroutine completes with a result or an exception.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/start-coroutine.html