What is the purpose of anko-recyclerview-v7-corout...
# android
a
What is the purpose of anko-recyclerview-v7-coroutines, and how does one use it? I cannot find much of anything using Google beyond either the GitHub repo or casual mentions of it as dependencies.
Just to be clear, I understand what co-routines are, it's what is is adding to the recyclerview that's the question.
s
From the source code¹, it looks like it adds the following: –
fun RecyclerView.onChildAttachStateChangeListener
fun RecyclerView.onItemTouchListener
¹ https://github.com/Kotlin/anko/blob/master/anko/library/generated/recyclerview-v7-coroutines/src/ListenersWithCoroutines.kt
As with many other Anko libraries, it adds convenience extension functions. simple smile
a
Those listeners are already on the RecyclerView.
I've used RecyclerView.OnItemTouchListener in previous projects, but I'm unclear on what is added by Anko, and how to use it properly. Can one use the Anko RecyclerView co-routine library independent from the Anko RecyclerView layout builder? Does it allow processing on a background thread, as the default context is UI? The documentation is extremely sparse.
s
Yeah, it seems to extend those two listeners and process stuff in the coroutine context that was provided with the extension functions, @andre.artus.
By using
launch
and invoking the handlers in its callback.