override fun showRendering(rendering: Rendering) {
messageView.setOnClickListener { rendering.onClick(Unit) }
}
This means it will be set (unnecessarily) at every
Rendering
state change. I don't imagine click listeners to be dynamic very often. What is the reasoning?
r
Ray Ryan
06/15/2020, 3:28 PM
They may well change on each rendering (and in earlier versions of the library did). It is none of the view’s business whether that is true or not. And anyway, any mechanism to allow the view to decide whether or not to update that pointer is going to be more complex and costly than simply setting it.
👍 1
Ray Ryan
06/15/2020, 3:45 PM
Similar reasoning for lack of debouncing of redundant update calls to views in general: a view is in the best position to decide whether it’s already showing value “Foo”, and whether it should invalidate itself or not.
b
Bruno Kongawi
06/15/2020, 4:35 PM
Gotcha. Thanks.
z
Zach Klippenstein (he/him) [MOD]
06/15/2020, 4:45 PM
This pattern also exists in Compose, FYI. When you pass a callback to a composable, you often just do it inline. If your function gets re-invoked, it will pass the lambda again.
👍 1
b
Bruno Kongawi
06/15/2020, 4:47 PM
I haven't played around with Compose yet. Will check it out some day soon. Thanks @Zach Klippenstein (he/him) [MOD]