Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import Dip
  2.  
  3. //1
  4. enum Tags: String, DependencyTagConvertible {
  5. case taggedClock
  6. }
  7.  
  8. private let container = DependencyContainer { container in
  9.  
  10. //2
  11. container.register(tag: Tags.taggedClock) { InitializerClock(identifier: Tags.taggedClock.rawValue) as Clock }
  12. container.register(tag: "Tagged") { InitializerClock(identifier: "Tagged") as Clock }
  13. }
  14.  
  15. //3
  16. let taggedClock: InitializerClock = try! container.resolve(tag: Tags.taggedClock)
  17. let anotherClock: InitializerClock = try! container.resolve(tag: "Tagged")
  18.  
  19. /*
  20. * Output:
  21. * creating InitializerClock with identifier: taggedClock
  22. * creating InitializerClock with identifier: Tagged
  23. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement