Olivier Patry
08/01/2023, 11:50 AMmikehearn
08/01/2023, 11:52 AMmikehearn
08/01/2023, 11:52 AMArkadii Ivanov
08/01/2023, 11:58 AMOlivier Patry
08/01/2023, 12:06 PMfun main(args: Array<String>) {
val lifecycle = LifecycleRegistry()
val rootComponentContext = DefaultComponentContext(lifecycle)
application {
...
}
}
Olivier Patry
08/01/2023, 12:07 PMrunOnUiThread
util thoughArkadii Ivanov
08/01/2023, 12:11 PMapplication
?Olivier Patry
08/01/2023, 12:27 PMRootComponentContext
which is then provided to compose runtime with ProvideComponentContext(rootComponentContext) {}
Maybe I miss something then.
I think I started this from a sample in a blog post.Olivier Patry
08/01/2023, 12:29 PMOlivier Patry
08/01/2023, 12:32 PMDefaultRootComponent
available 🤔Olivier Patry
08/01/2023, 12:36 PMOlivier Patry
08/01/2023, 12:39 PMChildStack
in a nested composable, maybe this is why my navigation state is loss?
I might have to store it in my RootComponent
if I properly understandArkadii Ivanov
08/01/2023, 12:42 PMremember
-ed things (including ChildStack
) are getting lost when you move the window to another display.Arkadii Ivanov
08/01/2023, 12:43 PMOlivier Patry
08/01/2023, 12:48 PMArkadii Ivanov
08/01/2023, 12:49 PMArkadii Ivanov
08/01/2023, 12:50 PMOlivier Patry
08/01/2023, 12:51 PMArkadii Ivanov
08/01/2023, 1:07 PMapplication {}
composition gets restarted (disposed and then a new composition started), which causes the navigation state to reset.
Here is a fix from the top of my head (didn't try to run), in case you prefer to keep your way of doing navigation.
fun main() {
var savedState: ParcelableContainer? = null
val instanceKeeper = InstanceKeeperDispatcher()
application {
val lifecycle = remember { LifecycleRegistry() }
val stateKeeper = remember { StateKeeperDispatcher(savedState = savedState) }
DisposableEffect(stateKeeper) {
onDispose { savedState = stateKeeper.save() }
}
val rootComponentContext =
DefaultComponentContext(
lifecycle = lifecycle,
stateKeeper = stateKeeper,
instanceKeeper = instanceKeeper,
)
val windowState = rememberWindowState()
LifecycleController(lifecycle, windowState)
// The rest of the code
}
}
Olivier Patry
08/01/2023, 1:42 PMmohamed rejeb
08/02/2023, 9:51 AMArkadii Ivanov
08/02/2023, 9:54 AMremember
-ed objects. It appears that the whole application
composition gets disposed and a new one started.mikehearn
08/02/2023, 10:03 AMArkadii Ivanov
08/02/2023, 10:08 AMAlexander Maryanovsky
08/04/2023, 8:49 AMAlexander Maryanovsky
08/04/2023, 8:50 AMOlivier Patry
08/04/2023, 9:08 AMOlivier Patry
08/18/2023, 7:31 AM