Created
December 10, 2018 17:00
-
-
Save Oni-zerone/2174b6c1f422d468313d468c272e8559 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class Builder<Context> { | |
public init() { } | |
open func build(_ context: Context) -> UIViewController? { | |
return nil | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol AbstractFactory { | |
associatedtype Context | |
var context: Context { get } | |
func make(from builder: Builder<Context>) -> UIViewController? | |
func getBuilder(from builderContainer: BuilderContainer) -> Builder<Context>? | |
} | |
public extension AbstractFactory { | |
func make(from builder: Builder<Context>) -> UIViewController? { | |
return builder.build(self.context) | |
} | |
func getBuilder(from container: BuilderContainer) -> Builder<Context>? { | |
return container.getBuilder(Context.self) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol BuilderContainer { | |
func getBuilder<Context>(_ contextType: Context.Type) -> Builder<Context>? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment