SideEffect
@Composable
@ExplicitGroupsComposable
public fun SideEffect(effect: () -> Unit)
Schedule effect to run when the current composition completes successfully and applies changes.
SideEffect can be used to apply side effects to objects managed by the composition that are not
backed by snapshots so as not to leave those
objects in an inconsistent state if the current composition operation fails.
effect will always be run on the composition's apply dispatcher and appliers are never run
concurrent with themselves, one another, applying changes to the composition tree, or running
RememberObserver event callbacks. SideEffects are always run after RememberObserver event
callbacks.
A SideEffect runs after every recomposition. To launch an ongoing task spanning potentially
many recompositions, see LaunchedEffect. To manage an event subscription or other object
lifecycle, see DisposableEffect.
