TaskDispatchers


Interface providing access to CoroutineDispatchers used for task execution inside a Compose hierarchy.

import androidx.compose.material3.Text
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalTaskDispatchers

val taskDispatchers = LocalTaskDispatchers.current
LaunchedEffect(taskDispatchers) {
    withContext(taskDispatchers.IO) {
        // Perform background I/O operations using the provided IO context
    }
}
Text("TaskDispatchers Sample")

Summary

Public properties

CoroutineDispatcher

A CoroutineDispatcher optimized for performing CPU-intensive work outside of the UI thread.

Cmn
CoroutineDispatcher

A CoroutineDispatcher designed for offloading blocking I/O tasks to a shared pool of threads.

Cmn

Public properties

Default

val DefaultCoroutineDispatcher

A CoroutineDispatcher optimized for performing CPU-intensive work outside of the UI thread.

IO

val IOCoroutineDispatcher

A CoroutineDispatcher designed for offloading blocking I/O tasks to a shared pool of threads.