Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new Compose Multiplatform Lifecycle (and maybe ViewModel) #695

Open
DatL4g opened this issue Apr 17, 2024 · 4 comments
Open

Support new Compose Multiplatform Lifecycle (and maybe ViewModel) #695

DatL4g opened this issue Apr 17, 2024 · 4 comments
Labels
backlog The task is postponed enhancement New feature or request

Comments

@DatL4g
Copy link
Contributor

DatL4g commented Apr 17, 2024

Will this https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-lifecycle.html be integrated in any form?

@arkivanov
Copy link
Owner

Eventually might be. This is being tracked in arkivanov/Essenty#157.

@arkivanov
Copy link
Owner

Let's keep this issue open for Decompose-related discussions.

@AndrazP
Copy link

AndrazP commented Aug 27, 2024

I noticed an issue with ViewModel lifecycle when an animation is set to Children stack.
If animation is set, ViewModel will be cleared on navigation pop and then immediately created again.

Example of navigating from the list to the details screen and back:

  1. List viewModel init()
  2. nav.push(RootConfig.Details...)
  3. Details viewModel init()
  4. navigation.pop()
  5. Details viewModel onCleared()
  6. Details viewModel init() // Issue

Example Children stack snippet:

@Composable
private fun Children(component: RootComponent, modifier: Modifier = Modifier) {
    Children(
        stack = component.stack,
        animation = stackAnimation { child, otherChild, _ ->
                slide(animationSpec = tween(easing = LinearEasing)) + fade()
        }
        modifier = modifier
    ) {
        Surface(modifier = Modifier.fillMaxSize()) {
            val child = it.instance
            CompositionLocalProvider(LocalViewModelStoreOwner provides child.viewModelStore) {
                when (child) {
                    is RootComponent.Child.List -> ListRoute(child.component)
                    is RootComponent.Child.Details -> DetailsRoute(child.component)
                    ....

KMP, Wasm only for now, Decompose 3.1, Koin 3.6.0-Beta5, Compose 1.6.11, Jetbrains Viewmodel 2.8.0
Lifecycle was configured as in Minesweeper
I don't know the state of Multiplatform ViewModel support, so I'm asking here instead of creating a separate bug.

@arkivanov
Copy link
Owner

@AndrazP that looks related to Decompose-ViewModel interop described here, not to KMP Lifecycle support. Please submit a new issue with a reproducer code/project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog The task is postponed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants