Quick question regarding Ui models for compose. I ...
# compose
x
Quick question regarding Ui models for compose. I have a scenario where I have a list column with cells. Each cell is represented by an instance of a
CellUiModel
data class. I want to hoist an action for cell click, and I'm torn between two approaches: • Add an
id
to the ui model and have an
onCellClick: (Int) -> Unit
passed to the Composable ◦ Feels more natural not having functional variables in models • Add a lambda property
onClick: () -> Unit
to the
CellUiModel
◦ Great for the type safety, but a bit weird How would you approach it? Is there any performance considerations here?
v
onCellClick: (Int) -> Unit
or even
onCellClick: (CellUiModel) -> Unit
to not bother at the controller side to find the clicked model by id
x
Could you give me PRO's vs CON's? I'd like something to support the decision
v
I just generally don't like idea putting callbacks into data classes.
h
I suggest
onCellClick: (CellUiModel) -> Unit
passed to the composable. It is easier to maintain and understand
👍 2
x
I'll go with that one then. Thanks folks! 🙏🏻