Ashu
10/26/2021, 6:40 PMZach Klippenstein (he/him) [MOD]
10/26/2021, 7:23 PMmkrussel
10/26/2021, 7:26 PMAshu
10/27/2021, 8:23 AMval hideBottomSheet by hideBottomSheetFlow.collectAsState()
coroutineScope.launch {
if (hideBottomSheet) bsScaffoldState.hide()
else bsScaffoldState.show()
}
Here launch is showing "warning error" that Calls to launch should happen inside a LaunchedEffect and not composition
mkrussel
10/27/2021, 12:30 PMcollectAsState
does a launch for you inside a LaunchedEffect
.Zach Klippenstein (he/him) [MOD]
10/28/2021, 4:57 PMhideBottomSheetFlow
can just call the show/hide methods itself. If you need to wire up events from a composable like this, you’d want to do something like this:
LaunchedEffect(hideBottomSheetFlow) {
hideBottomSheetFlow.collect { hideBottomSheet ->
if (hideBottomSheet) bsScaffoldState.hide() else bsScaffoldState.show()
}
}
collectAsState
here because that flow doesn’t represent state, it’s events.