Find LiveData.observeAsState() calls — prefer collectAsStateWithLifecycle()

Proprietary

observeAsState() ties subscription to the composition, not to the lifecycle owner — collection keeps running while the host activity is STOPPED. Migrate to StateFlow and collectAsStateWithLifecycle() (or stay on LiveData and use androidx.lifecycle.compose.observeAsState, which is lifecycle-aware in newer versions).

org.openrewrite.kotlin.compose.FindObserveAsState$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.compose.FindObserveAsState$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.