I have a data model like below,
[Car Brand] has [Types] has Year or specific model (string)
for example
BMW > Z4 > 2005
BMW > Z3 > 1999
BMW > Z3 > 2001
Porshe > Carrera > 1999
Audi > TT > 2002
The yearView backgroundColor has to be changed after selection. I added a tapGesture to the yearView and then tried to listen all the yearViews from Type Cell
var carForType = PublishSubject<SelectedCar>() // in class property
let bv = yearContainer(frame: .zero, withOption: option)
bv.tap.rx.event.asObservable().map({ _ -> Selected in
return SelectedBet.init(car: nil, type: self.type, year: option)
})
.bind(to: self.typeForCar)
.disposed(by: self.disposeBag)
And from the TableVC I'm trying to get all the selected cars
cell.selectedCars.debug().subscribe(onNext: {
var car = $0
pBet.brand = self.viewModel.brand
print(car)
}).disposed(by: self.disposeBag)
But after scroll it double subscribes to the cells and overall I started to think that there should be a better way to do it. It would be great to opinions about how to simplify, I'm willing to change all the structure.
Note: Project is using MVVM and RxDataSources extension.