Olivier Patry
03/21/2021, 10:56 PMDisposableEffect
to cleanup some resources hosted by a state object.
When I close the window using the system close button, my onDispose {}
isn't called (but `Window`'s onDismissRequest {}
is).
Is it expected? I feel it buggy, I would expect composable being disposed explicitly, no?jim
03/22/2021, 7:27 AMIgor Demin
03/22/2021, 8:22 AMOlivier Patry
03/22/2021, 8:28 AMOlivier Patry
03/22/2021, 8:29 AMOlivier Patry
03/22/2021, 8:37 AMOlivier Patry
03/22/2021, 8:51 AMfun main() {
Window(
size = IntSize(800, 600),
onDismissRequest = {
println("Window.onDismissRequest CALLED")
}
) {
var clickCount by remember { mutableStateOf(0) }
if (clickCount < 5) {
DisposableEffect(Unit) {
onDispose {
println("DisposableEffect.onDispose CALLED")
}
}
Text("Hello World! $clickCount", Modifier.clickable { ++clickCount })
} else {
Text("Clicked too much! $clickCount")
}
}
}