Swift UI mvi enhancements - #47
Conversation
1. Separation of concerns: ViewModel has more responsibility then storing the view state I can imagine that in the future we want to have some kind of middleware before the intent handler (for the observability events for example) for that we need a separate view model and it needs to be open for inheritance).
|
Im not sure i follow, do you mean in the case that a customer copies the code for the journey view and wants to add their own state? i guess so, but i guess it depends, as an implementer do i want my custom state to be the first class state, or the journey state?
yeah this is just wishful thinking if we can use iOS 17. im just wondering also with the enum state way, even though it may guide you into not making invalid states, it also can limit the person customising the journey. what may be an invalid in a OOTB journey, may not be after adding some custom state on top of it, which would make you have to ditch all the screens built in stuff probably. but maybe that is an unlikely scenario. Im also wondering that some customers may want to combine viewmodels potentially, and then 2 viewmodels may want to interact in the same screen, the enum scenario might make this difficult to do as the valid states would be totally different. it does require the implementer to have a deeper understanding of whats going on though, but they would have more freedom to do the changes they need.
for 1, the previous viewmodel implementation wasnt even a viewmodel really, it didnt do much besides forwarding intents to the intent handler and had a property for state. so for sepration of concerns i felt like the viewmodel had no concerns to begin with really. |
Main changes:
Stateis now @observable for better performance, each property publishes individually instead of the entire state