Skip to content

Instantly share code, notes, and snippets.

@V8tr
Last active August 6, 2018 08:38
Show Gist options
  • Save V8tr/044dc47776cfd0ae628f3fcea16d718e to your computer and use it in GitHub Desktop.
Save V8tr/044dc47776cfd0ae628f3fcea16d718e to your computer and use it in GitHub Desktop.
Refactoring Massive App Delegate using Command pattern. See blog post for more details: https://www.vadimbulavin.com/refactoring-massive-app-delegate
protocol Command {
func execute()
}
struct InitializeThirdPartiesCommand: Command {
func execute() {
// Third parties are initialized here
}
}
struct InitialViewControllerCommand: Command {
let keyWindow: UIWindow
func execute() {
// Pick root view controller here
keyWindow.rootViewController = UIViewController()
}
}
struct InitializeAppearanceCommand: Command {
func execute() {
// Setup UIAppearance
}
}
struct RegisterToRemoteNotificationsCommand: Command {
func execute() {
// Register for remote notifications here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment