Florian
08/29/2021, 6:27 PMSideEffect
here. The functionality works without the SideEffect
call. Can someone tell me why we need it?
https://google.github.io/accompanist/systemuicontroller/Adam Powell
08/29/2021, 6:33 PM@Composable
function shouldn't have observable side effects until after that transaction commits successfully. SideEffect {}
does this, deferring its block of code until the composition transaction that scheduled it is successful.Adam Powell
08/29/2021, 6:35 PMSideEffect
is also guaranteed to run that code on the applier thread (e.g. the Android UI thread) whereas composition itself may run on a background thread in the futureAdam Powell
08/29/2021, 6:36 PMSideEffect
you can meet this contract. Otherwise you would need to ensure yourself that no mutations you make are visible externally before composition succeeds.Florian
08/29/2021, 6:44 PMSideEffect
the call to setSytemBarsColor
would execute if the Composable was canceled for some reason?Florian
08/29/2021, 6:44 PMAdam Powell
08/29/2021, 9:22 PMFlorian
08/30/2021, 8:12 AM