MVVM_Swift
MVVM_Swift copied to clipboard
Why viewController updating Cell in MVVM
according to me cell should update itself not viewConroller should update the label in the cell I am just asking for the learning point of view
self.dataSource = EmployeeTableViewDataSource(cellIdentifier: "EmployeeTableViewCell", items: self.employeeViewModel.empData.data, configureCell: { (cell, evm) in
cell.employeeIdLabel.text = evm.id
cell.employeeNameLabel.text = evm.employeeName
})
the code above is not correct for me it should be like blow
self.dataSource = EmployeeTableViewDataSource(cellIdentifier: "EmployeeTableViewCell", items: self.employeeViewModel.empData.data, configureCell: { (cell, evm) in
cell.employee = evm
})
what do you think ?
I dont think so. As the View doesn’t know that the Model exists and vice versa because all communication occurs between the ViewModel.