Skip to content
This repository was archived by the owner on Jan 30, 2021. It is now read-only.
This repository was archived by the owner on Jan 30, 2021. It is now read-only.

Unbalanced calls to begin/end appearance transition #49

@ahtierney

Description

@ahtierney

Currently the app coordinator launches the app with:

    func start(animated: Bool, completion: VoidClosure?) {
        // Configure window/root view controller
        window.setRootViewController(rootController, animated: false, completion: {
            self.window.makeKeyAndVisible()
            // Spin off auth coordinator

This creates a warning about unbalanced calls to the rootController which is not guaranteed to have finished displaying.

I'm proposing that we fix this one of two ways:

// Simply
        window.setRootViewController(rootController, animated: false, completion: {
            self.window.makeKeyAndVisible()
            DispatchQueue.main.async {
            // Spin off auth coordinator

or

// a more complex but "more correct" solution, something like:
struct LaunchBehavior: ViewControllerLifecycleBehavior {
    let onLaunch: VoidClosure
    func afterAppearing(_ viewController: UIViewController, animated: Bool) {
        onLaunch()
    }
}
    func start(animated: Bool, completion: VoidClosure?) {
        let onLaunch = LaunchBehavior() { [weak self] in
            // Spin off auth coordinator
        }
        rootController.addBehaviors([onLaunch])

        window.setRootViewController(rootController, animated: false, completion: {
            self.window.makeKeyAndVisible()
        })

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions