Not sure if this is a bug or not but, when I creat...
# compose
v
Not sure if this is a bug or not but, when I create a scaffold, I have an event that triggers opening the drawer. However this only works once, once I fire more close events it doesn’t close the drawer.
Copy code
val state = viewModel.state.observeAsState().value ?: return
val scaffoldState = rememberScaffoldState()
when (state.drawerEvent?.consume()) {
    DrawerState.OPEN -> {
        scaffoldState.drawerState.open()
    }
    DrawerState.CLOSE -> {
        scaffoldState.drawerState.close()
    }
}
Scaffold(scaffoldState = scaffoldState)
d
This seems a bit weirdly written and I think you have a side effect in there.
Try something like this.
Copy code
LaunchedEffect(Unit) {
    viewModel.state.collect {
        /* drawer open/close here */
    }
}
v
Nevermind it’s an issue on my end, thanks for the help, wasn’t aware of launchedEffect.