10/09

첫 번째는 CollectionView.rx.willDisplayCell를 활용했다

input.viewWillAppearEvent
            .withLatestFrom(input.willDisplayCell)
            .withUnretained(self)
            .bind(onNext: { owner, indexPath in
                print("willDisplayCell", indexPath)
                owner.searchLocationUseCase.updateStoreCellObservable(index: indexPath.row, storeList: owner.storeList)
            })
            .disposed(by: disposeBag)
func updateStoreCellObservable(index: Int, storeList: [StoreVO]) {
        realmRepository.updateStoreCellObservable(index: index, storeList: storeList)
            .subscribe(with: self, onSuccess: { owner, storeVO  in
                owner.updateStoreVO.onNext(storeVO)        
            }, onFailure: { owner, error in
                owner.errorSubject.onNext(error)
            })
            .disposed(by: disposebag)
    }
self.searchLocationUseCase.updateStoreVO
            .withLatestFrom(input.willDisplayCell) { storeVO, willDisplayCell in
                return (storeVO, willDisplayCell)
            }
            .withUnretained(self)
            .bind(onNext: { owner, visibleStore in
                let (storeVO, willDisplayCell) = visibleStore
                let visibleStore = owner.storeList[willDisplayCell.row]
            
                if owner.shouldUpdateStore(store: storeVO, visibleStore: visibleStore) {
                        owner.storeList[willDisplayCell.row] = storeVO
                        output.storeList.accept(owner.storeList)
                }
            })
            .disposed(by: disposeBag)
        
        transformCollectionViewDataSource(input: input, output: output)
        
        return output
    }

두 번째는 rx.items에서 필터링을 하는 방법을 사용했다.

output.storeCollectionViewDataSource
            .bind(to: locationView.storeCollectionView.rx.items(cellIdentifier: "StoreCollectionViewCell", cellType: StoreCollectionViewCell.self)) { [weak self]
                index, item, cell in
                
                if let updatedItem = self?.viewModel.updateStoreCell(item) {
                    cell.configureCell(item: updatedItem)
                }
            }
            .disposed(by: disposeBag)
Observable.zip(locationView.storeCollectionView.rx.modelSelected(StoreVO.self), locationView.storeCollectionView.rx.itemSelected)
            .withUnretained(self)
            .bind(onNext: { [weak self] data in
                if let updatedItem = self?.viewModel.updateStoreCell(data.1.0) {