Guest User

Untitled

a guest
Feb 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. struct MyViewModel: ViewModel {
  2. // thanks to protocol composition we define only the services we want to use
  3. typealias Services = HasService1 & HasService2
  4. init(withServices services: Services) {
  5. services.service1.executeService1()
  6. services.service2.executeService2()
  7. }
  8. }
  9.  
  10. struct MyOtherViewModel: ViewModel {
  11. typealias Services = HasService2 & HasService3
  12. init(withServices services: Services) {
  13. services.service2.executeService2()
  14. services.service3.executeService3()
  15. }
  16. }
Add Comment
Please, Sign In to add comment