actionViewEvents

Create a Flow of action view events on the MenuItem instance where the value emitted is one of the 2 event types: MenuItemActionViewEvent.Collapse, MenuItemActionViewEvent.Expand

Parameters

handled

function to be invoked with each value to determine the return value of the underlying MenuItem.OnActionExpandListener. Note that the Flow will only emit when this function evaluates to true.

Note: Created flow keeps a strong reference to the MenuItem instance until the coroutine that launched the flow collector is cancelled.

Example of usage:

menuItem.actionViewEvents { it.menuItem.isChecked }
.onEach { event ->
when(event) {
is MenuItemActionViewEvent.Collapse -> {
// handle collapse event
}
is MenuItemActionViewEvent.Expand -> {
// handle expand event
}
}
}
.launchIn(uiScope)