Skip to content

Instantly share code, notes, and snippets.

@srdanrasic
Last active February 10, 2018 20:02
Show Gist options
  • Select an option

  • Save srdanrasic/7e02198085ed3083f29e8e4ff766edaa to your computer and use it in GitHub Desktop.

Select an option

Save srdanrasic/7e02198085ed3083f29e8e4ff766edaa to your computer and use it in GitHub Desktop.
extension ProfileViewController {
static func makeViewController(_ userService: UserService) -> ProfileViewController {
let viewController = ProfileViewController()
viewController.nameLabel.text = userService.user.name
viewController.imageView.imageUrl = userService.user.imageUrl // Assuming using an image caching libary
userService.friends.bind(to: viewController.friendsView) { cell, friend in
cell.nameLabel.text = friend.name
}
viewController.logoutButton.reactive.tap
.observeNext(with: userService.logOut)
.dispose(in: viewController.bag)
return viewController
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment