LaunchedEffect
Deprecated LaunchedEffectNoParamError
@Composable
public fun LaunchedEffect(block: suspend CoroutineScope.() -> Unit): 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 key
parameter.
@Composable
public fun LaunchedEffect(key1: 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 key1
. 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 key1
. Instead, see
rememberCoroutineScope
to obtain a CoroutineScope
that may be used to launch ongoing jobs
scoped to the composition in response to event callbacks.
@Composable
public fun LaunchedEffect(key1: Any?, key2: 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 key1
or key2
. 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.
@Composable
public fun LaunchedEffect(
key1: Any?,
key2: Any?,
key3: 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 key1
, key2
or key3
. 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.
@Composable
public fun LaunchedEffect(vararg keys: 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 keys
. 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.