childAttachStateChangeEvents

Create a Flow of child attach state change events on the RecyclerView instance where the value emitted is one of the 2 event types: RecyclerViewChildAttachStateChangeEvent.Attached, RecyclerViewChildAttachStateChangeEvent.Detached

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

Example of usage:

recyclerView.childAttachStateChangeEvents()
.onEach { event ->
when(event) {
is RecyclerViewChildAttachStateChangeEvent.Attached -> {
// handle attached event
}
is RecyclerViewChildAttachStateChangeEvent.Detached -> {
// handle detached event
}
}
}
.launchIn(uiScope)