Skip to content

Instantly share code, notes, and snippets.

@dkulundzic
Created February 2, 2023 12:46
Show Gist options
  • Save dkulundzic/1509bebf4d8cd0de6760b370792e0aca to your computer and use it in GitHub Desktop.
Save dkulundzic/1509bebf4d8cd0de6760b370792e0aca to your computer and use it in GitHub Desktop.
An abstraction for a predefined set of functionality, aimed to be ran once, at app startup
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
StartupProcessService()
.execute(process: AppearanceCustomisationStartupProcess())
.execute(process: AppsFlyerStartupProcess(delegate: self))
.execute(process: FacebookStartupProcess(application: application, launchOptions: launchOptions))
.execute(process: GoogleServicesStartupProcess(messagingDelegate: self))
.execute(process: MixpanelStartupProcess(launchOptions: launchOptions))
return true
}
public protocol StartupProcess {
func run(completion: @escaping (Bool) -> Void)
}
public final class StartupProcessService {
public init() { }
@discardableResult
public func execute(process: StartupProcess) -> StartupProcessService {
process.run { guard $0 else { return } }
return self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment