alexhelder
07/25/2025, 12:24 AMdata class HomeCallbacks(
val onCallback1: () -> Unit,
val onCallback2: () -> Unit,
val onCallback3: () -> Unit,
)
fun HomeScreen(
state: HomeState,
callbacks: HomeCallbacks = HomeCallbacks()
) {
// ...
}
Pablichjenkov
07/25/2025, 12:33 AMJonathan
07/25/2025, 3:53 AMsealed classes
to represent different events you want to observe. I think it makes the calling code cleaner and makes adding new "events" dirt simple. Using a sealed class in a when statement has to be exhaustive so you don't have to worry about forgetting to implement an event.Pablichjenkov
07/25/2025, 4:25 AMKamilH
07/25/2025, 7:11 AMsealed Event
solutions, I’ve always wondered about the memory impact, especially for quickly occurring events like OnTextChanged
, etc. I’ve never measured it, though, and I think this could be mitigated by using a value class
The downside is also that we are tightly coupling UI components with events unless we use lambdas everywhere and the “event sink” on the “screen” levelJonathan
07/25/2025, 12:04 PMdata object
so you’d have as little allocations as possible.