rxdatasources

RxDataSources collection view cell always uses fade for insert cell animation, can't change to a different animation

依然范特西╮ 提交于 2020-01-16 08:35:15
问题 I am having an issue with cell animations using RxSwift on a UICollectionView , my simple setup is as follows: collectionView.register(UINib(nibName: "CustomCollectionCell", bundle: nil), forCellWithReuseIdentifier: "cell") let dataSource = RxCollectionViewSectionedAnimatedDataSource<SectionOfCustomDataAnimated>( animationConfiguration: AnimationConfiguration(insertAnimation: .bottom, reloadAnimation: .bottom, deleteAnimation: .bottom), configureCell: { dataSource, cv, indexPath, element in

Cannot set bind(to: UITableView) with RxSwift Variable asObservable()

故事扮演 提交于 2019-12-25 00:34:26
问题 I'm trying to bind(to:) a collectionView, but the tableView doesn't work either. I have a viewModel where is my Variable<[]> and I want to subscribe when the value changes, with my tableView. viewModel.theVariable .asObservable() .bind(to: tableView.rx.items(cellIdentifier: "Cell", cellType: UITableViewCell.self)){ (row, item, cell) in cell.textLabel?.text = item } .addDisposableTo(disposeBag) The XCode tells me Type 'inout UITableView' does not conform to protocol 'ReactiveCompatible' which

RxDataSources tableView with multiple sections from one API source

旧街凉风 提交于 2019-12-08 12:52:54
问题 Currently for our API requests we use Rx. An example of how we use it is: let orderRxService = OrderRxService.listAsShop(shopId, status: .active) .repeatRequest(delay: 4) .observeOn(MainScheduler.instance) .subscribe( onNext: { [weak self] orders in self?.orders = orders self?.tableView.reloadData() }) .disposed(by: disposeBag) This gets all orders for given shopId with the status .active . On every update the local orders object is replaced and the tableView is reloaded. This reload the

RxDataSources - How to add a custom empty cell when there's no data

限于喜欢 提交于 2019-12-06 11:33:23
问题 struct MyViewModel { var items: Observable<String> //.... } // In view controller viewModel.items.bind(to: tableView.rx.items(cellIdentifier: "Cell", cellType: MyCell.self)) { index, model, cell in //... } .disposed(by: disposeBag) If I have a another cell called EmptyCell , and I want to display this cell if the items is empty. How could I achieve this. 回答1: The RxDataSources data source should consist of any piece of state or data you want to display in your cells. For this reason you might

Subscription to a UIButton.rx.tap located in UITableViewCell within UITableViewDataSource

夙愿已清 提交于 2019-12-05 05:02:42
问题 Let's say I have a UIButton in a UITableViewCell . After dequeuing the cell from the UITableView I want to subscribe to the UIButton.rx.tap . The issue is that if my UITableViewCell is dequeued multiple times, the subscriptions would retain. Currently I solve this problem by allocating a Disposable property in my UITableViewCell , setting it when the subscription is create, and calling Disposable.dispose() on UITableViewCell.prepareForReuse() , however as far as I understand implementing

Subscription to a UIButton.rx.tap located in UITableViewCell within UITableViewDataSource

邮差的信 提交于 2019-12-03 20:55:09
Let's say I have a UIButton in a UITableViewCell . After dequeuing the cell from the UITableView I want to subscribe to the UIButton.rx.tap . The issue is that if my UITableViewCell is dequeued multiple times, the subscriptions would retain. Currently I solve this problem by allocating a Disposable property in my UITableViewCell , setting it when the subscription is create, and calling Disposable.dispose() on UITableViewCell.prepareForReuse() , however as far as I understand implementing features in a way that requires you to call Disposable.dispose() implies that you are doing something wrong