I am actually considering not using Sealed Class at all, not even for state.
My ViewModel is made of two sets of elements:
- Events
- StateManager
Events are extension functions defined directly on the shared ViewModel class. These are basically the intents, but they are just normal functions, called directly by the UI layer.
StateManager is a component internal to the ViewModel itself, which has the role of managing the State. It’s also where StateFlow is defined.
State Reducers are simply extension functions of the StateManager.
The State Reducers are called directly by the Event functions.
If you use SealedClass Intents, you would have one single reducer function, processing all intents.
If each StateReducer is a function on its own, you can organize the state reducers in different files, kept together by topic/context.