Where should I write the logics in didSelectItemAt in UICollectionView with VIPER?

104 views Asked by At

I have a UICollectionView with VIPER:

//MARK: - UICollectionViewDataSource
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return presenter?.getCertsCount(status: getCertStatus()) ?? 0
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? MyCertificationCell {
            if let certs = presenter?.getCerts(status: getCertStatus()) {
                cell.cert = certs[indexPath.item]
            }
            
            return cell
        }
        
        return UICollectionViewCell()
    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        
    }

But where I should write the logic when didSelectItemAt like making a network request or pushing a new ViewController. In Presenter or Interactor or ViewModel ?

0

There are 0 answers