more features • Run for deadline => Do you try to update / add functions after 1-2 months later? https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 11
requests, fetch Core Data objects, validate input...) • Deliver necessary data to view controllers to display: Date/String format. • Update and listen to changes in models https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 16
• Massive View Controller will become Massive ViewModel • MVC is has better speed of the development. • Hard to design the ViewModel. https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 19
them of interaction events (same as MVC). • View controller can't talk to models directly, they only interact with view models and views. https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 21
that represent a value ‘over time’ • FRP is programming with asynchronous data streams. • ... https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 31
only knows how to present the data. • Bad viewModel.title .map { $0 + "!!!" } // View should not modify the data .bindTo(self.titleLabel) • Good viewModel.title .bindTo(self.titleLabel) https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 52
View can only communicate to ViewModel about what View did. • Bad viewModel.login() // Bad: View should not know what ViewModel does (login) • Good self.loginButton.rx_tap .bindTo(viewModel.loginButtonDidTap) // "Hey I clicked the login button" https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 53
only exposes the minimum data so that View can render. • Bad struct ProductViewModel { let product: Driver<Product> // Bad: ViewModel should hide Model } • Good struct ProductViewModel { let productName: Driver<String> let formattedPrice: Driver<String> } https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 54
expose as String. => Oops, we are doing it wrong too. • Don't make ViewModelM become Presenter layer: number of rows, color... https://dangthaison91.wordpress.com | fb.me/dangthaison.91 | @dangthaison91 55