Reputation: 29
First of all, here is my code
viewModel.price
.drive(collectionView.rx.items(cellIdentifier: "Cell")) { (index: Int, Info, cell: Cell) in
....
}.disposed(by: disposeBag)
viewModel.price's data type is Driver<[Info]>
In this code, I want to add a flag which is for pausing collectionView.
When the flag from viewModel is "true" then keep drawing collectionView but if it's "false" then stop it.
I think I need to use combineLatest and takeWhile but not sure how to use this.
how can I use combineLatest and takeWhile for my code?
Upvotes: 0
Views: 425
Reputation: 569
Try this:
Driver.combineLatest(viewModel.price, viewModel.shouldDraw)
.filter { $1 }
.map { $0.0 }
.drive(collectionView.rx.items(cellIdentifier: "Cell")) { (index: Int, Info, cell: Cell) in
....
}.disposed(by: disposeBag)
Upvotes: 2