Configuration closure in Swift
Issue #2
When I was reading through Swinject, I found something interesting https://github.com/Swinject/Swinject/blob/master/Sources/Container.swift
1 | public convenience init(parent: Container? = nil, registeringClosure: (Container) -> Void) { |
The init
has a closure
that makes configuration easy, much like a Builder
pattern. So I think we can learn from that and make a Configurable
protocol
1 | protocol Configurable: class {} |
With this, we can init some class with less hassle
1 | let view = UIView().config { |