Last active
February 10, 2018 20:46
-
-
Save srdanrasic/c0077cc445d4d1179e71e804d04722c6 to your computer and use it in GitHub Desktop.
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
extension ProfileViewController { | |
static func makeViewController(_ userService: UserService) -> ProfileViewController { | |
let viewController = ProfileViewController() | |
... | |
viewController.friendsView.reactive.selectedItem | |
.with(latestFrom: userService.friends, combine: itemAtIndex) // Take element at selected index from friends array | |
.bind(to: viewController) { viewController, friend in | |
let userService = userService.makeUserService(for: friend) | |
viewController.presentFriendViewController(userService) | |
} | |
... | |
} | |
private func presentFriendViewController(_ userService: UserService) { | |
let viewController = ProfileViewController.makeViewController(userService) | |
present(viewController, animated: true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment