Skip to content

Instantly share code, notes, and snippets.

@V8tr
Last active June 13, 2021 18:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save V8tr/8c3803be69b8ba3bccffab377cf51c7e to your computer and use it in GitHub Desktop.
Save V8tr/8c3803be69b8ba3bccffab377cf51c7e to your computer and use it in GitHub Desktop.
Refactoring Massive App Delegate using Composite pattern. See blog post for more details: https://www.vadimbulavin.com/refactoring-massive-app-delegate
class PushNotificationsAppDelegate: AppDelegateType {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// Registered successfully
}
}
class StartupConfiguratorAppDelegate: AppDelegateType {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Perform startup configurations, e.g. build UI stack, setup UIApperance
return true
}
}
class ThirdPartiesConfiguratorAppDelegate: AppDelegateType {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Setup third parties
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment