Last active
August 3, 2018 08:04
-
-
Save V8tr/0bfa78ea06aa522b0b5e72328d83d4fc 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
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
enum AppDelegateFactory { | |
static func makeDefault() -> AppDelegateType { | |
return CompositeAppDelegate(appDelegates: [PushNotificationsAppDelegate(), StartupConfiguratorAppDelegate(), ThirdPartiesConfiguratorAppDelegate()]) | |
} | |
} | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
let appDelegate = AppDelegateFactory.makeDefault() | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
_ = appDelegate.application?(application, didFinishLaunchingWithOptions: launchOptions) | |
return true | |
} | |
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
appDelegate.application?(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment