What should be done when a component has too many ...
# compose
e
What should be done when a component has too many inputs and events? Is there such a thing as too many inputs/events from a single component?
Copy code
MyComponent(
  input1...,
  inputN,
  event1...,
  eventN
)
d
Something something... slot api
s
Typically, divide the component up into smaller parts and pass some of the data/events via slots
If you actually use that much stuff, it’s ok to make a class to wrap stuff up too (e.g. TextStyle)
e
@Sean McQuillan [G] like
Copy code
onAddTrackToPlaylist: (PlaylistTrackEvent) -> Unit = {},
    onRemoveTrackFromPlaylist: (PlaylistTrackEvent) -> Unit = {},
s
That’s fine
until you cross 7 params, that’s just a normal large composable
e
@Dominaezzz I'm looking into slot api thanks
c
A good example of slot api is the material scaffold api.
Also this is related and applicable to compose: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1601088624095100
e
I've looked into slots and it turns out I use it but didn't know what it was called but not what I'm looking for