MVVM_Swift icon indicating copy to clipboard operation
MVVM_Swift copied to clipboard

Why viewController updating Cell in MVVM

Open sultan-arshi opened this issue 3 years ago • 1 comments

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 ?

sultan-arshi avatar Jun 06 '21 07:06 sultan-arshi

I dont think so. As the View doesn’t know that the Model exists and vice versa because all communication occurs between the ViewModel.

Dast1Woop avatar Aug 23 '22 09:08 Dast1Woop