LaunchedEffect

fun LaunchedEffect(block: suspend CoroutineScope.() -> Unit)

When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext. The coroutine will be cancelled when the LaunchedEffect leaves the composition.

It is an error to call LaunchedEffect without at least one subject parameter.

@ComposableContract(restartable = false)
fun LaunchedEffect(subject: Any?, block: suspend CoroutineScope.() -> Unit)

When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext. The coroutine will be cancelled and re-launched when LaunchedEffect is recomposed with a different subject. The coroutine will be cancelled when the LaunchedEffect leaves the composition.

This function should not be used to (re-)launch ongoing tasks in response to callback events by way of storing callback data in MutableState passed to subject. Instead, see rememberCoroutineScope to obtain a CoroutineScope that may be used to launch ongoing jobs scoped to the composition in response to event callbacks.

@ComposableContract(restartable = false)
fun LaunchedEffect(subject1: Any?, subject2: Any?, block: suspend CoroutineScope.() -> Unit)

When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext. The coroutine will be cancelled and re-launched when LaunchedEffect is recomposed with a different subject1 or subject2. The coroutine will be cancelled when the LaunchedEffect leaves the composition.

This function should not be used to (re-)launch ongoing tasks in response to callback events by way of storing callback data in MutableState passed to key. Instead, see rememberCoroutineScope to obtain a CoroutineScope that may be used to launch ongoing jobs scoped to the composition in response to event callbacks.

@ComposableContract(restartable = false)
fun LaunchedEffect(subject1: Any?, subject2: Any?, subject3: Any?, block: suspend CoroutineScope.() -> Unit)

When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext. The coroutine will be cancelled and re-launched when LaunchedEffect is recomposed with a different subject1, subject2 or subject3. The coroutine will be cancelled when the LaunchedEffect leaves the composition.

This function should not be used to (re-)launch ongoing tasks in response to callback events by way of storing callback data in MutableState passed to key. Instead, see rememberCoroutineScope to obtain a CoroutineScope that may be used to launch ongoing jobs scoped to the composition in response to event callbacks.

@ComposableContract(restartable = false)
fun LaunchedEffect(vararg subjects: Any?, block: suspend CoroutineScope.() -> Unit)

When LaunchedEffect enters the composition it will launch block into the composition's CoroutineContext. The coroutine will be cancelled and re-launched when LaunchedEffect is recomposed with any different subjects. The coroutine will be cancelled when the LaunchedEffect leaves the composition.

This function should not be used to (re-)launch ongoing tasks in response to callback events by way of storing callback data in MutableState passed to key. Instead, see rememberCoroutineScope to obtain a CoroutineScope that may be used to launch ongoing jobs scoped to the composition in response to event callbacks.