Last active
May 22, 2019 18:54
-
-
Save gringoireDM/bb3a09ecce31dd6437fd79ff346df197 to your computer and use it in GitHub Desktop.
An example of AppDelegate using MERLin
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
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
var moduleManager: BaseModuleManager = BaseModuleManager() | |
var router: SimpleRouter! | |
lazy var eventsListeners: [AnyEventsListening] = { | |
[ | |
ConsoleLogEventsListener(), | |
RoutingEventsListener(withRouter: router) | |
] | |
}() | |
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { | |
router = SimpleRouter(withFactory: moduleManager) | |
moduleManager.addEventsListeners(eventsListeners) | |
eventsListeners.forEach { $0.registerToEvents(for: self) } | |
return true | |
} | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
window = UIWindow() | |
window?.rootViewController = router.rootViewController(forLaunchOptions: launchOptions) | |
window?.makeKeyAndVisible() | |
_events.onNext(.didFinishLaunching) | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment