Fudge
07/26/2020, 4:33 PM@Composable suspend fun askQuestion() : Answer {
return suspendCoroutine { continuation ->
QuestionComponent(onAnswer = {answer -> continuation.resume(answer)})
}
}
The problem is that if I do something like this
setContent {
runBlocking { askQuestion() }
}
It won't compile because "@Composable invocations can only happen from the context of a @Composable function"Adam Powell
07/26/2020, 4:34 PMAdam Powell
07/26/2020, 4:35 PMFudge
07/26/2020, 4:36 PMAdam Powell
07/26/2020, 4:36 PMAdam Powell
07/26/2020, 4:37 PMAdam Powell
07/26/2020, 4:37 PMSnackMenu
class - that's the hoisted state object bridging suspending request-response API with compose-aware stateAdam Powell
07/26/2020, 4:38 PMAdam Powell
07/26/2020, 4:40 PMFudge
07/26/2020, 4:42 PMFudge
07/26/2020, 4:43 PMAdam Powell
07/26/2020, 4:44 PMAdam Powell
07/26/2020, 4:45 PMFudge
07/26/2020, 4:46 PMprivate constructor
do exactly that?Fudge
07/26/2020, 4:47 PMclass Snack private constructor(...)
Adam Powell
07/26/2020, 4:47 PMAdam Powell
07/26/2020, 4:47 PMSnack
class or its companion object could call itAdam Powell
07/26/2020, 4:48 PMAdam Powell
07/26/2020, 4:48 PMLeland Richardson [G]
07/26/2020, 7:10 PMLeland Richardson [G]
07/26/2020, 7:12 PM