dimanche 30 mai 2021

MVVM Swift datasource calling service without RxSwift

I am trying to using MVVM and my final solution like below, But i am not sure it is true in terms of SOLID principles. Because I making service call in a viewcontroller. Is it okay ? Or How my approach should be?

class ViewController: UITableViewController {

let dataSource = CustomDataSource()

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.dataSource = customdataSource

    customdataSource.dataChanged = { [weak self] in
        self?.tableView.reloadData()
    }

    dataSource.serviceCall("https:/..")
  }
}

Please don`t ask me share CustomDataSource and its service call, it is basically a subclass and UITableViewDataSource, if i share all code the question could be more complicated.

Aucun commentaire:

Enregistrer un commentaire