David W
04/19/2022, 6:24 AM@Composable
, which doesn't exist in the business layer. Any patterns on how to structure that? I'll put what I have so far in the thread.suspend fun installFromUnknownSource(
promptUserToReplaceExistingFolder: suspend (modInfo: ModInfo) -> Boolean
)
@Composable
suspend fun DuplicateModAlertDialog(modInfo: ModInfo): Boolean {
return suspendCoroutine { cont ->
// stuff
cont.resume(...)
}
}
installFromUnknownSource(
promptUserToReplaceExistingFolder = { modInfo ->
DuplicateModAlertDialog(modInfo)
})
Adam Powell
04/19/2022, 1:40 PMSnackbarHostState
publishes data for composables to display. It uses a suspend function to show a notification and get a return value for whether the snackbar was dismissed or if the user pressed a button for that message https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material/material/src/commonMain/kotlin/androidx/compose/material/SnackbarHost.kt;l=60?q=SnackbarHostState&sq=David W
04/20/2022, 1:57 AMshowSnackbar
creates a new (observable) state that contains a continuation, then suspends. The Snackbar is then created/shown in response to the newly created state and invokes the continuation when the user interacts with it.Adam Powell
04/20/2022, 1:58 AMshowSnackbar
no longer cares, it can cancel its call and it will be removed from the queue; if it was currently being shown it will move on to the next oneDavid W
04/20/2022, 2:05 AMfinally {
currentSnackbarData = null
}
?Adam Powell
04/20/2022, 2:05 AM