Thanks Dmytro for a nice introduction to the power of protocols!
Though I have one suggestion ––
CompositeStore could also conform to
Store and then you can have even more composition since now you can pass a
CompositeStore inside another
CompositeStore since it’s also a
Store and now imagine all the infinite possibilities…
In the last couple of my client projects, I have been following the exact same approach i.e. using enums+protocols! This one time I had to move from GA to Mixpanel and it didn’t effect my controllers at all which was such an amazing feeling :)
It’s fine if you like them but when I use them I see too much code, too much abstraction, more maintainabilty. I have seen the implementations but sorry it doesn’t look good to me. As I said I’m happy with MVVM & protocols. They are enough to decouple my views, make my controllers reusable and testable.
Yes I have tried it, it’s like VIPER as well and I have my concerns with all such design patterns which makes you create a lot of boilerplate for no reason. MVVM & protocols are enough for me 🙂
Hey, even though we can‘t declare a property like you mentioned above but the way I use it is make your `ViewModel` conform with your `DataProvider` and satisfy all the requirements. This way you won’t need to save a direct reference of DataProvider but rather save a reference of your ViewModel which conforms to DataProvider. I hope I made it clear and it helps :)