I am currently working a project with a requirement to refactor the RxSwift
dependencies for introduce PromiseKit
.
I am not hugely familiar with RxSwift
or PromiseKit
so please forgive me if this is an obvious one.
I am looking for a way to handle the Zip use case still
override func start() -> Observable<CoordinationResult> {
let tabBarController = UITabBarController()
let tabs: [SectionTab] = [.feed]
let coordinationResults = Observable.from(configure(tabBarController: tabBarController, withTabs: tabs)).merge()
window.rootViewController = tabBarController
window.makeKeyAndVisible()
return coordinationResults
.take(1)
}
private func configure(tabBarController: UITabBarController, withTabs tabs: [SectionTab]) -> [Observable<Void>] {
let navControllers = tabs
.map { tab -> UINavigationController in
let navController = BaseNavigationController()
navController.tabBarItem = UITabBarItem(title: tab.title, image: nil, selectedImage: nil)
return navController
}
tabBarController.viewControllers = navControllers
tabBarController.view.backgroundColor = UIColor.white // Fix dark shadow in nav bar on segue
return zip(tabs, navControllers)
.map { (tab, navController) in
switch tab {
case .feed:
let coordinator = FeedCoordinator(navigationController: navController, dependencies: dependencies)
return coordinate(to: coordinator)
}
}
}
From what I understand, Zip
combines 2 Observables and allows you to action on them, emitting a single observable, which is essentially the result of the 2 original observables and your action.