itemSelections

fun NavigationBarView.itemSelections(): Flow<MenuItem>

Create a Flow of item selected events on the NavigationBarView instance where the value emitted is the currently selected menu item.

Note: if a MenuItem is already selected, it will be emitted immediately upon collection.

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

Example of usage:

bottomNavigationView.itemSelections()
.onEach { menuItem ->
// handle menuItem
}
.launchIn(uiScope)

navigationRailView.itemSelections()
.onEach { menuItem ->
// handle menuItem
}
.launchIn(uiScope)

fun NavigationView.itemSelections(): Flow<MenuItem>

Create a Flow of item selected events on the NavigationView instance where the value emitted is the currently selected menu item.

Note: if a MenuItem is already selected, it will be emitted immediately upon collection.

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

Example of usage:

navigationView.itemSelections()
.onEach { menuItem ->
// handle menuItem
}
.launchIn(uiScope)

fun BottomNavigationView.itemSelections(): Flow<MenuItem>

Deprecated

Use NavigationBarView.itemSelections(): Flow<MenuItem> instead.

Create a Flow of item selected events on the BottomNavigationView instance where the value emitted is the currently selected menu item.

Note: if a MenuItem is already selected, it will be emitted immediately upon collection.

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

Example of usage:

bottomNavigationView.itemSelections()
.onEach { menuItem ->
// handle menuItem
}
.launchIn(uiScope)