but upgrading to build 150+ on my: ```val remember...
# compose-desktop
d
but upgrading to build 150+ on my:
Copy code
val rememberedScaffoldState: ScaffoldState = rememberScaffoldState(drawerState)
...
rememberedScaffoldState.drawerState.close()
I get
Copy code
Suspend function 'close' should be called only from a coroutine or another suspend function
how to workaround that??
j
I can only assume your
rememberedScaffoldState.drawerState.close()
is occurring within an onclick handler, not in your composable function, right? It's unclear from your code snippet, but calling it from a composable function would be very wrong. To answer your question though, you will probably need to 
launch
 it into a coroutine scope.  https://kotlinlang.org/docs/reference/coroutines/basics.html You can get a coroutine scope something like this:
Copy code
@Composble fun demo() {
    val scope = rememberCoroutineScope()
    Button(
        onClick={
            scope.launch { drawerState.close() }
        }
    )
}
d
can you elaborate on why it is such a good idea to call close() (or what kind of methods) in a scope? eager to learn why it is a good idea ...
j
All suspend functions must be called from a coroutine scope, it is a requirement of Kotlin. You should probably learn all about coroutines in Kotlin before proceeding: https://kotlinlang.org/docs/reference/coroutines/coroutines-guide.html
d
oh, I know that scope functions need to be called inside a scope. Wanted to know why this is important for a function like 'close()' whats the special need to be inside a scope there?
j
The close function does not return immediately. It triggers a close animation and suspends until that close animation is completed. You do not want to block the UI thread for the duration of the animation, so it must be a non-blocking suspend function.
1