Created
August 19, 2017 15:28
-
-
Save Herakleis/93500056e417acee0902937bc71d610f to your computer and use it in GitHub Desktop.
BindableType
This file contains hidden or 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
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