Skip to content

Instantly share code, notes, and snippets.

@albertodebortoli
Last active November 28, 2019 11:19
Show Gist options
  • Save albertodebortoli/693dc4b1b415682bf9399dae2e916f3a to your computer and use it in GitHub Desktop.
Save albertodebortoli/693dc4b1b415682bf9399dae2e916f3a to your computer and use it in GitHub Desktop.
used by 'A Smart Feature Flagging System for iOS' article on Medium
static let tweakManager: TweakManager = {
// mutable configuration (to override tweaks from other configurations)
let userDefaultsConfiguration = UserDefaultsConfiguration(userDefaults: .standard)
// remote configurations (optional)
let optimizelyConfiguration = OptimizelyConfiguration()
let firebaseConfiguration = FirebaseConfiguration()
// local JSON configuration (default tweaks)
let jsonFileURL = Bundle.main.url(forResource: "ExampleConfiguration", withExtension: "json")!
let localConfiguration = LocalConfiguration(jsonURL: jsonFileURL)
// priority is defined by the order in the configurations array (from highest to lowest)
let configurations: [Configuration] = [userDefaultsConfiguration,
optimizelyConfiguration,
firebaseConfiguration,
localConfiguration]
return TweakManager(configurations: configurations)
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment