Re: ordering between callbacks and data. Is there ...
# compose
e
Re: ordering between callbacks and data. Is there any style guide around if to put required callbacks like onClick before or after data? Button puts it first for instance which implies callbacks goes first, but I've seen the opposite as well. Curious to hear if there's a concensus.
s
I don't think there's a strong consensus on it, besides the most important part of keeping the non optional parameters first, then modifier, then the rest optional ones. https://github.com/androidx/androidx/blob/androidx-main/compose%2Fdocs%2Fcompose-component-api-guidelines.md The section about parameter order touches on this, but no hard rules besides what I say above
e
What would be your approach?
s
Most "important" ones go further up. So for a button component, the click feels like the most important. For our components, we typically pass in data first and callbacks later, but I'd reconsider this every time I make a new component to see if it "feels" right for that component itself.