Reputation: 337
We have a Core library that provides shared logic across our iOS app. Inside this library, we use an enum
as a configuration container, storing various static properties (mainly closures).
The entities inside the Core library access these configurations to determine behavior. However, we need a way to allow the app to override these settings at runtime without modifying the Core library itself.
Example:
enum Config {
static var loader: () -> LoaderProtocol = { DefaultLoader() }
}
class SomeCoreController {
func showLoader() {
let loader = Config.loader()
loader.start()
}
}
Config.loader = { CustomLoader() }
The enum
is getting cluttered with many unrelated settings.
A way for organizing such a configuration system.
A clean way to allow overriding behavior at the application level
Upvotes: 0
Views: 19