Middle — Senior
Analysis of problems in the implementation of AppCoordinator
livecode
Task condition
This example shows a coordinator class responsible for displaying the profile screen and handling the user logout event. Note the use of RxSwift, DisposeBag, and capturing navigationController in the closure.
final class AppCoordinator {
let navigationController: UINavigationController
let disposeBag = DisposeBag()
func presentProfile() {
let controller = ProfileController()
controller.rx.didTapLogout
.bind(onNext: { [weak navigationController] in
navigationController?.popToRootViewController(animated: true)
})
.disposed(by: disposeBag)
navigationController.present(controller, animated: true)
}
}