Yan Pujante
06/01/2021, 5:15 PMval userPreference = UserPreference()
Window(
size = userPreference.windowSize,
resizable = true,
title = "Test",
events = WindowEvents(onResize = userPreference::onWindowResize)
) {
App(userPreference)
}
to the new Window api. It looks like I can use val state = rememberWindowState(size = userPreference.windowSize)
, but I am not sure how to call onWindowResize
when state.size
changes...Igor Demin
06/02/2021, 8:07 AMval state = rememberWindowState()
Window(state) {
}
LaunchedEffect(state) {
snapshotFlow { state.size }
.onEach(::onWindowResize)
.launchIn(this)
snapshotFlow { state.position }
.filterNot { it.isInitial }
.onEach(::onWindowRelocate)
.launchIn(this)
}
(similar to listening the other hoisted states, like LazyListState)Yan Pujante
06/02/2021, 1:41 PMIgor Demin
06/02/2021, 1:44 PMdescription about itWe forgot about it and added it recently. Thanks for bringing this š
Yan Pujante
06/02/2021, 1:59 PMLaunchedEffect
section inside the Window
callback allow the application to terminate properly...Igor Demin
06/02/2021, 3:28 PMWindow
scope.
Because when we close the window - we will cancel all launched inside Window
coroutines.
If we launch coroutines inside application
- we can't cancel them.