Skip to content

Instantly share code, notes, and snippets.

@Herakleis
Created August 19, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Herakleis/93500056e417acee0902937bc71d610f to your computer and use it in GitHub Desktop.
Save Herakleis/93500056e417acee0902937bc71d610f to your computer and use it in GitHub Desktop.
BindableType
import UIKit
import RxSwift
protocol BindableType {
associatedtype ViewModelType
var viewModel: ViewModelType! { get set }
func bindViewModel()
}
extension BindableType where Self: UIViewController {
mutating func bindViewModel(to model: Self.ViewModelType) {
viewModel = model
loadViewIfNeeded()
bindViewModel()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment