Logic Outside Composables

Why Logic Does Not Belong in a Composable

A composable may be called at any time, skipped, or called every frame (How Recomposition Works), a bad home for anything that must run once or outlive the screen:

The fix splits the screen in two. A state holder owns the data and rules (what the cart holds, how search filters, when to load); the UI turns state into pixels and reports what the user did. Screen-level state belongs in a ViewModel, the Jetpack 234 class built to survive configuration changes and to own coroutines that outlive a composition.