Coroutine Builders
Coroutine builders define ways of starting a coroutine from a suspend
lambda and obtaining an object representing its execution.
val result = coroutineBuilder(prms) {
... suspend lambda ...
}
Builder | Return | Description |
---|---|---|
Starts a coroutine from a |
||
Starts a coroutine from a |
||
Start a coroutine and obtain a |
||
|
Starts a coroutine and blocks for its conclusion, returning the resulting value directly. |
Coroutine Builders
Coroutine dispatchers define the threading policy for the coroutine execution, i.e., they define the threads where the coroutine continuations are executred. Dispatchers are typically provided as parameters to the coroutine builder.
val result = coroutineBuilder(coroutineDispatcher) {
... suspend lambda ...
}
Dispatcher | Description |
---|---|
Uses the static |
|
Starts the coroutine in the current thread. Continuations are executed in the thread that triggered the coroutine resumption. |
|
Schedules coroutine execution in the Android main UI thread. |