Android Integrations
Modo provides Android integrations with ViewModel and Lifecycle support through LocalLifecycleOwner
, LocalViewModelStoreOwner
, and LocalSavedStateRegistryOwner
. This allows you to use functions like viewModel
to obtain Android ViewModel
.
Lifecycle
Since Modo provides Lifecycle support, let's take a look at what specific lifecycle events mean in the context of Screen Lifecycle:
Lifecycle.Event.ON_CREATE
- called once per screen when the screen is created.Lifecycle.Event.ON_START
andLifecycle.Event.ON_RESUME
- dispatched whenScreen.Content
is composed for the first time.Lifecycle.Event.ON_PAUSE
andLifecycle.Event.ON_STOP
- dispatched whenScreen.Content
leaves the composition.Lifecycle.Event.ON_DESTROY
- called once per screen when it is removed from the navigation graph.
For correctly handling Lifecycle.Event
from your Screen.Content
, we recommend using the built-in screen effects. The LifecycleScreenEffect
is a convenient way to subscribe to a screen's Lifecycle.
ViewModel
You can use functions provided by Jetpack Compose to get a ViewModel
.