Skip to content

Simplify the code to add ViewModel LifecycleEventObserver to local lifecycle owner #35

Description

@dmitriy-chernysh

Move addObserver() to rememberViewModel fun

        val viewModel = rememberViewModel<SomeViewModel>(
            modules = {
                listOf(featureSomeModule)
            }
        )

        LaunchedEffect(lifecycleOwner) {
            lifecycleOwner.lifecycle.addObserver(viewModel)
        }

BaseViewModel should inherit LifecycleEventObserver

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions