Skip to content

Instantly share code, notes, and snippets.

@AdiD253
Created December 27, 2018 10:09
Show Gist options
  • Save AdiD253/e98b53f8af40a6284471f42bc29d05aa to your computer and use it in GitHub Desktop.
Save AdiD253/e98b53f8af40a6284471f42bc29d05aa to your computer and use it in GitHub Desktop.
fun <T : List<DiffItem>, R : RecyclerView.ViewHolder> autoNotifyDelegate(adapter: RecyclerView.Adapter<R>, initialValue: T): ReadWriteProperty<Any?, T> =
object : ObservableProperty<T>(initialValue) {
override fun afterChange(property: KProperty<*>, oldValue: T, newValue: T) {
adapter.autoNotify(oldValue, newValue)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment