CombineCommunity / CombineCocoa

Combine publisher bridges for UIKit
MIT License
1.67k stars 133 forks source link

Collection view publishers should not have an effect before subscription #62

Open RoryKelly opened 3 years ago

RoryKelly commented 3 years ago

Describe the bug simply referencing the willDisplayCellPublisher will change the delegate of your collection view. This should only happen After subscription.

    var willDisplayCellPublisher: AnyPublisher<(cell: UICollectionViewCell, indexPath: IndexPath), Never> {
        let selector = #selector(UICollectionViewDelegate.collectionView(_:willDisplay:forItemAt:))
        return delegateProxy.interceptSelectorPublisher(selector)
            .map { ($0[1] as! UICollectionViewCell, $0[2] as! IndexPath) }
            .eraseToAnyPublisher()
    }