Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow is not released when embedded in UINavigationController #197

Closed
mashe opened this issue Dec 9, 2024 · 0 comments · Fixed by #198
Closed

Flow is not released when embedded in UINavigationController #197

mashe opened this issue Dec 9, 2024 · 0 comments · Fixed by #198
Assignees

Comments

@mashe
Copy link
Contributor

mashe commented Dec 9, 2024

Lets say there is a Flow that is can be presented modally as well as pushed to the navigational stack:

final class ExampleFlow: Flow {
    let root: Presentable
    
    init() {
        let viewModel = ExampleModel()
        let viewController = ExampleController(viewModel: viewModel)
        self.root = viewController
    }

}

And it is possible navigate by pushing:

private func navigateToRecoveryCode() -> FlowContributors {
        let flow = ExampleFlow()
        Flows.use(flow, when: .created) { (root) in
            rootNavigationController.pushViewController(viewController, animated: true)
        }
        return .one(
            flowContributor: .contribute(
                withNextPresentable: flow,
                withNextStepper: DefaultStepper()
            )
        )
    }
}

or by presenting modally:

private func navigateToRecoveryCode() -> FlowContributors {
        let navigationController = navigationController()
        let flow = ExampleFlow()
        Flows.use(flow, when: .created) { (root) in
            navigationController.viewControllers = [root]
            rootNavigationController.present(navigationController, animated: true)
        }
        return .one(
            flowContributor: .contribute(
                withNextPresentable: flow,
                withNextStepper: DefaultStepper()
            )
        )
    }
}

The problem comes from the idea that ExampleFlow.root.rxDismissed always emits an event on dismiss.
However, it never emits an event when root is embedded in UINavigationContoller.
Instead UINavigationController.rxDismissed emits an event.
The Flow design [proposed above] does not know anything about UINavigationController and I think it should be kept as it.

So my proposal is to update rxDismissed in a such way that it emits an event when parent navigation controller is dismissed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants