Djuro
01/13/2024, 11:22 AMComponentContext
for my app navigation. What I noticed is the following
I would sometimes have the following structure
init {
lifecycle.doOnCreate {
Logger.e { " in on created !!!!! "}
}
lifecycle.doOnDestroy {
Logger.e { " in on destroy !!!!! "}
}
}
inside of my components.
This works well for 🤖, but for 🍎 doOnCreate
block is executed after the component has been destroyed
Does someone have an idea on why this would be the case
Here is a log to see that those 2 calls happen immediately one after another. Again this is just for iOSArkadii Ivanov
01/13/2024, 1:25 PMDjuro
01/13/2024, 7:11 PMMainViewController
I had the following code:
import androidx.compose.runtime.remember
import androidx.compose.ui.window.ComposeUIViewController
import navigation.RootComponent
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
fun MainViewController() = ComposeUIViewController {
val root = remember {
RootComponent(DefaultComponentContext(LifecycleRegistry()))
}
App(root)
}
I had to change LifecycleRegistry()
to ApplicationLifecycle()
working code is the follwing
import androidx.compose.runtime.remember
import androidx.compose.ui.window.ComposeUIViewController
import navigation.RootComponent
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.lifecycle.ApplicationLifecycle
fun MainViewController() = ComposeUIViewController {
val root = remember {
RootComponent(DefaultComponentContext(ApplicationLifecycle()))
}
App(root)
}
Arkadii Ivanov
01/13/2024, 8:25 PMArkadii Ivanov
01/13/2024, 8:27 PMDjuro
01/13/2024, 8:27 PMDjuro
01/13/2024, 8:28 PMArkadii Ivanov
01/13/2024, 8:29 PMDjuro
01/13/2024, 8:29 PM