Created
February 21, 2020 22:36
-
-
Save helbertgs/e67c101d3ff540c71c066580630037eb to your computer and use it in GitHub Desktop.
This file contains 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
import UIKit | |
typealias Provider = NSObject & UIApplicationDelegate | |
class ComposedProvider: Provider { | |
// MARK: Property(ies). | |
private var providers: [Provider] | |
// MARK: Constructor(s). | |
init(with providers: [Provider] = []) { | |
self.providers = providers | |
} | |
// MARK: Funtion(s). | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { | |
print(#function) | |
let result = self.providers.reduce(true, { result, provider in | |
result && provider.application?(application, didFinishLaunchingWithOptions: launchOptions) ?? false | |
}) | |
return result | |
} | |
func applicationWillTerminate(_ application: UIApplication) { | |
self.providers.forEach { | |
$0.applicationWillTerminate?(application) | |
} | |
} | |
func applicationDidBecomeActive(_ application: UIApplication) { | |
self.providers.forEach { | |
$0.applicationDidBecomeActive?(application) | |
} | |
} | |
func applicationDidEnterBackground(_ application: UIApplication) { | |
self.providers.forEach { | |
$0.applicationDidEnterBackground?(application) | |
} | |
} | |
func applicationWillEnterForeground(_ application: UIApplication) { | |
self.providers.forEach { | |
$0.applicationWillEnterForeground?(application) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment