So, I am new to VIPER and have built simple demo app of http request using the architecture. I got an issue where the UI are not updated although the the method within the view is still called because I have checked that the print("test") is executed and shown on the debug console. This is the relevant code:
View :
private func getAllContacts(){
self.contacts = []
self.hud.show(in: self.view)
self.presenter?.fetchListContacts()
print("asd")
}
Presenter :
func fetchListContacts(){
print("sdf")
interactor?.getContacts()
}
Interactor :
func getContacts(){
print("123")
var contacts : [DetailContact] = []
contacts = \\APICALL
self.presenter?.listContactFetchSuccess(contacts)
}
Baxk to PResenter :
func listContactFetchSuccess(_ contacts: [DetailContact]) {
print("gxx")
view?.fetchSucceed(contacts: contacts)
}
back to View :
func fetchSucceed(contacts: [DetailContact]) {
self.contacts = contacts
self.hud.dismiss()
self.contactTableView.reloadData()
print("test")
}
My Router :
static func createListContactModule() -> ListViewController {
let view = mainstoryboard.instantiateViewController(withIdentifier: "ListViewController") as! ListViewController
var presenter: ViewToPresenterListProtocol & InteractorToPresenterListProtocol = ListContactPresenter()
var interactor: PresenterToInteractorListProtocol = ListContactInteractor()
let router:PresenterToRouterListProtocol = ListContactRouter()
view.presenter = presenter
presenter.view = view
presenter.router = router
presenter.interactor = interactor
interactor.presenter = presenter
return view
}