Created
February 2, 2023 12:46
-
-
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
This file contains hidden or 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
| 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 | |
| } |
This file contains hidden or 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
| public protocol StartupProcess { | |
| func run(completion: @escaping (Bool) -> Void) | |
| } |
This file contains hidden or 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
| 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