I am using Swift Bond for two-way binding of view with viewModel. This is achieved by bidirectionalBind.
Question is: What is a common practice of binding a model with a viewModel and more specifically how would model know about changes made in viewModel. In ReactiveCocoa there is RACChannel to do that, so you can bind viewModel and model without changing types of model's properties.
Main goal is to keep model very simple with only primitive types like String, Int, Date and move Observable and Property types to viewModel.
Illustration:
import Bond
import ReactiveKit
struct Person {
var name: String
var age: Int
var birthdate: Date
}
struct PersonViewModel {
fileprivate var person: Person
var name: Observable<String>
var age: Observable<Int>
var birthDate: Observable<Date>
init(person: Person) {
self.person = person
// what should go here in order to bind properties???
}
}