Created
March 24, 2018 17:07
-
-
Save isaac-weisberg/4c3da915bb5149a920dcf1f4080866de to your computer and use it in GitHub Desktop.
Global shared environment but with a twist
This file contains 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
class ArbitraryConfigurationData { | |
// content units references | |
} | |
extension Environment { | |
class func bootstrap(with configuration: ArbitraryConfigurationData) { | |
Environment.shared = Environment(with: configuration) | |
} | |
} | |
class Environment { | |
static private(set) var shared: Environment! | |
let config: ArbitraryConfigurationData | |
let providerOfSomeContent: ProviderOfSomeContent | |
let providerOfSomeOtherContent: ProviderOfSomeOtherContent | |
let providerOfSomeYetOtherContent: ProviderOfSomeYetOtherContent | |
private init(with configuration: ArbitraryConfigurationData) { | |
config = configuration | |
providerOfSomeContent = ProviderOfSomeContent(with: config) | |
providerOfSomeOtherContent = ProviderOfSomeOtherContent(with: config) | |
providerOfSomeYetOtherContent = ProviderOfSomeYetOtherContent(with: config) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment