Zoltan Demant
07/17/2023, 1:11 PMSheetState
such that onDismiss is invoked when the animation is finished? Example code in 🧵Zoltan Demant
07/17/2023, 1:13 PMStylianos Gakis
07/17/2023, 1:23 PMStylianos Gakis
07/17/2023, 1:23 PMZoltan Demant
07/17/2023, 1:24 PMZoltan Demant
07/17/2023, 1:26 PMStylianos Gakis
07/17/2023, 1:26 PMlaunch {
someSuspendFunction()
yourCallback()
}
should really be the exact same thing as
launch {
someSuspendFunction()
}.invokeOnCompletion {
yourCallback()
}
since the coroutine should suspend inside hide() until it’s properly done.Stylianos Gakis
07/17/2023, 1:27 PMStylianos Gakis
07/17/2023, 1:27 PMrememberCoroutineScope
?Zoltan Demant
07/17/2023, 1:27 PMStylianos Gakis
07/17/2023, 1:27 PMStylianos Gakis
07/17/2023, 1:28 PMStylianos Gakis
07/17/2023, 1:28 PMZoltan Demant
07/17/2023, 1:28 PMStylianos Gakis
07/17/2023, 1:28 PMStylianos Gakis
07/17/2023, 1:29 PM0,00001% chance that my debug build is actually the culpritAlways possible 😅
Zoltan Demant
07/17/2023, 1:29 PMStylianos Gakis
07/17/2023, 1:31 PMZoltan Demant
07/17/2023, 1:42 PMval AnimationSpec = SpringSpec<Float>()
and it makes me wonder if the lack of visibilityThreshold is causing the sheet to hide prematurely. Ill have to test this further before I can say for sure.Stylianos Gakis
07/17/2023, 1:44 PMStylianos Gakis
07/17/2023, 2:20 PMhide()
call. If you do the cleanup after it it won’t ever run in case of cancellation I don’t think. With the completion callback it should run always.
So I think that’s why they do it, not for any timing issues.jossiwolf
07/17/2023, 2:47 PMhide()
or show()
can be cancelled and would throw a CancellationException
in that case. invokeOnCompletion
vs try-catch doesn't make a difference in this case 🙂Zoltan Demant
07/17/2023, 2:47 PMStylianos Gakis
07/17/2023, 2:49 PMYeah I was comparing it with this, which would in fact be wrong right? The first option would not work properly in case of cancellationvs try-catchinvokeOnCompletion
jossiwolf
07/17/2023, 2:52 PMsomeSuspendFunction()
throws and yourCallback()
never executedefemoney
07/19/2023, 12:23 PM