MessageHost

fun MessageHost(viewModel: ScreenViewModel<*, *>, snackbarHostState: SnackbarHostState = rememberPageSnackbarHostState(), onAction: (UiMessage) -> Unit = {}, drawHost: Boolean = snackbarHostState !== LocalPageSnackbarHostState.current)(source)

Shows viewModel's queued messages, one at a time and in order, and tells it as each leaves.

By default the messages show through the Toolkit scaffold around the screen, a page's frame or the shell's tabs, which draws them above its bars and buttons. Given a host of its own, it draws that host here.

Parameters

onAction

Called when a message's action is pressed, before it is marked as shown.

drawHost

Whether to draw snackbarHostState here. By default only when it is not the scaffold's, which draws its own.


fun MessageHost(messages: ImmutableList<UiMessage>, onShown: (id: Long) -> Unit, snackbarHostState: SnackbarHostState = rememberPageSnackbarHostState(), onAction: (UiMessage) -> Unit = {}, drawHost: Boolean = snackbarHostState !== LocalPageSnackbarHostState.current)(source)

Shows messages one at a time, oldest first, calling onShown with each one's id once it has left. A message still on screen when this leaves composition is not marked as shown, so it shows again next time rather than being lost.