June 2018
Intermediate to advanced
316 pages
6h 34m
English
The launch function can be used as follows:
val job = launch { val suspendLambda = suspend { delay(1, TimeUnit.SECONDS) println("Hello from suspend lambda") } suspendLambda()}
The suspend modifier is used to specify that invoking of function can be suspended and can be called only from a coroutine. The delay function is a special function that can be used for examples or debugging. This function just pauses a coroutine on time that is passed as a parameter.
The launch function is a special function that can invoke suspend lambdas and functions:
public actual fun launch( context: CoroutineContext = DefaultDispatcher, start: CoroutineStart = CoroutineStart.DEFAULT, parent: Job? = null, block: suspend CoroutineScope.() -> ...
Read now
Unlock full access