How can i use Essenty's Lifecycle with composables...
# decompose
l
How can i use Essenty's Lifecycle with composables (multiplatform)? Should i have disposable and launched effects and manually link the events? (Not using Decompose, only Essenty)
a
Yes, you will have to drive the lifecycle manually. On Android you can get the lifecycle from the activity or fragment.
Also not sure about navigation. The lifecycle should follow I guess, and each screen should have its own lifecycle, perhaps.
l
In this case some helper function like
Copy code
@Composable
fun lifeCycleComposable(
    content: @Composable LifecycleRegistry.() -> Unit
) {
    val registry = LifecycleRegistry()
    LaunchedEffect(Unit){
        registry.onCreate()
        registry.onStart()
    }
    DisposableEffect(Unit){
        onDispose {
            registry.onDestroy()
        }
    }
    with(registry){
        content()
    }
}
might be useful, right? I'm trying to find a solution for destroying my viewmodels that i inject with koin because right now i think they're not being disposed, not sure i'm on the right track tho 😅
a
That's not so straightforward I guess. ViewModels are usually tied to the back stack.