Created
December 19, 2019 13:57
-
-
Save JoaquimLey/3781d5fef1f499f467fe522ea2e5a128 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.recyclerview.widget.ListAdapter | |
/** | |
* Creates a copy of itself if no new [data] is passed, this is used | |
* so [ListAdapter] correctly diffs and animates. :facepalms: | |
*/ | |
fun <T> List<T>.refresh(data: List<T> = this): List<T> { | |
return mutableListOf<T>().apply { addAll(data) }.toList() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment