Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct MyViewModel: ViewModel {
- // thanks to protocol composition we define only the services we want to use
- typealias Services = HasService1 & HasService2
- init(withServices services: Services) {
- services.service1.executeService1()
- services.service2.executeService2()
- }
- }
- struct MyOtherViewModel: ViewModel {
- typealias Services = HasService2 & HasService3
- init(withServices services: Services) {
- services.service2.executeService2()
- services.service3.executeService3()
- }
- }
Add Comment
Please, Sign In to add comment