flingEvents

fun RecyclerView.flingEvents(handled: (FlingEvent) -> Boolean = { true }): Flow<FlingEvent>

Create a Flow of fling events on the RecyclerView instance.

Parameters

handled

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

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.flingEvents { it.velocityX != 0 }
.onEach { event ->
// handle fling event
}
.launchIn(uiScope)