I’ve an architectural question. I like working with the InteractionSource when I need to do complex ...
a
I’ve an architectural question. I like working with the InteractionSource when I need to do complex event management between different composables. I prefer it over multiple callbacks everywhere. I generally add new classes implementing a custom sub interface of Interaction and handle those events in the respective composables or view models. I’m not sure however if there are any big reasons against this or if it is “against” some compose guidelines.
l
Are these events UI 'events' like hover / focus? Or are you using it for events at your data layer
a
Hmm… they are things like drag and drop and drawing selection boxes over multiple items
So ik the view models they are consumed and eventually trigger state and data changes
So “complicated” UI events
l
InteractionSource isn't really meant to be used as a generic event bus for things that are not transient / live longer than the UI. So if this actually lives in the view model, I think it's probably a bit out of what it is intended for. That said internally it's just a state flow, so it is probably even easier to build your own for your specific use cases, instead of trying to repurpose interaction source as a generic event bus here
a
Great! Thanks for the answer!