attachEvents

Create a Flow of view attach events on the View instance where the value emitted is one of the 2 event types: ViewAttachEvent.Attached, ViewAttachEvent.Detached

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

Example of usage:

childView.attachEvents()
.onEach { event ->
when(event) {
is ViewAttachEvent.Attached -> {
// handle attached event
}
is ViewAttachEvent.Detached -> {
// handle detached event
}
}
}
.launchIn(uiScope)