Skip to content

Instantly share code, notes, and snippets.

@isaac-weisberg
Created March 24, 2018 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaac-weisberg/4c3da915bb5149a920dcf1f4080866de to your computer and use it in GitHub Desktop.
Save isaac-weisberg/4c3da915bb5149a920dcf1f4080866de to your computer and use it in GitHub Desktop.
Global shared environment but with a twist
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