You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm reaching out to inquire about the correctness of my implementation for handling model binding with payloads in the Epoxy library. I fully understand, in such use-case, using the concept of payloads may not provide significant efficiency benefits. However, I'm exploring this library and I want just understand fundamental concepts, including working with payloads.
And the most important question for me, should I call super.bind(view, previouslyBoundModel) when payloads is empty?
@EpoxyModelClass
abstract class SampleModel : EpoxyModel<View>() {
companion object {
private const val FIRST_CHANGED = 0
private const val SECOND_CHANGED = 1
private const val THIRD_CHANGED = 2
}
@EpoxyAttribute
lateinit var first: Int
@EpoxyAttribute
lateinit var second: Int
@EpoxyAttribute
lateinit var third: Int
override fun getDefaultLayout() = R.layout.item_sample
override fun bind(view: View, previouslyBoundModel: EpoxyModel<*>) {
if (previouslyBoundModel !is SampleModel)
return super.bind(view, previouslyBoundModel)
val payloads = mutableListOf<Any>()
if (first != previouslyBoundModel.first)
payloads.add(FIRST_CHANGED)
if (second != previouslyBoundModel.second)
payloads.add(SECOND_CHANGED)
if (third != previouslyBoundModel.third)
payloads.add(THIRD_CHANGED)
if (payloads.isNotEmpty())
bind(view, payloads)
}
override fun bind(view: View, payloads: MutableList<Any>) {
if (payloads.contains(FIRST_CHANGED))
view.first.text = first.toString()
if (payloads.contains(SECOND_CHANGED))
view.second.text = second.toString()
if (payloads.contains(THIRD_CHANGED))
view.third.text = third.toString()
}
override fun bind(view: View) {
view.first.text = first.toString()
view.second.text = second.toString()
view.third.text = third.toString()
}
}
The text was updated successfully, but these errors were encountered:
Hello, I'm reaching out to inquire about the correctness of my implementation for handling model binding with payloads in the Epoxy library. I fully understand, in such use-case, using the concept of payloads may not provide significant efficiency benefits. However, I'm exploring this library and I want just understand fundamental concepts, including working with payloads.
And the most important question for me, should I call
super.bind(view, previouslyBoundModel)
when payloads is empty?The text was updated successfully, but these errors were encountered: