问题标签 [rxdatasources]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1093 浏览

ios - 如何使用 RxDataSources 避免重复点击 Tableview 上的按钮

我有一个带有 RxDataSources 的表格视图,其中单元格项目有一个删除图标。当单元格出列并单击该删除图标时,将触发所有先前的单击事件,从而重复点击。项目单元格:

单元格视图模型:

单元格和 ViewModel 绑定的视图控制器视图模型:

视图控制器:

控制台调试:

0 投票
3 回答
920 浏览

swift - How to reflect the new section to UICollectionView in RxDataSource?

I am building an iOS app with RxSwift and RxDataSource using VIPER architecture. I want to change the content of the UICollectionView as the value of the presenter changes (as the user typed in some letters in the searchBar, the collectionView should show all users' profile that starts with the letters), but it doesn't work as I wanted it to.

By trying debug() function, the value of presenter.section in ViewController (which holds the content of the CollectionView) is changed after I typed in some letters in the searchBar. However, the collectionView is not reflecting the change. Here are the main parts of the code.

code of ViewController

code of Presenter

How I defined dataSource

  • ViewController has the instance of Presenter, and the presenter has an instance called section. This section holds the list of the users whose username is starting with specific letters.

Could you please help me? If I have left anything unclear, please let me know in the comment.

Update: output of the debug()

0 投票
1 回答
1388 浏览

uitableview - 使用 RxSwift 在 UITableView 中进行 2 路绑定

我将 MVVM 模式与RxSwiftRxCocoaRxDataSources 一起使用

在此处输入图像描述

我已经通过使用成功填充了存在的UITableView数组,但它是一种方式绑定。PaletteViewModelListViewModelRxDataSource

我想实现我在图片中显示的内容,即我想将UITextFieldfrom绑定UITableViewCellObservable数组中某个索引处存在的ListViewModel

我想2 way binding处理. UITextField_ 如果用户更改 textField 中的文本,它应该更改特定索引处存在的 answer 属性中的值,反之亦然。answerPaletteViewModel

MVVM pattern我怎样才能使用ReactiveX框架来实现这样复杂的事情?

如果UITableViewCellat someIndexPath由于不可见而从内存中删除,并且 observable 的值发生更改,会导致崩溃,因为UITextFieldatIndexPath将返回 nil?

0 投票
1 回答
143 浏览

ios - UIcollectionView - 创建填充项目网格的水平滚动寻呼机

我正在从android开发应用程序端口。在我的应用程序中,在其中一个屏幕中,我向用户展示了按部分分组的参数集合。每个部分都显示为可跨网格中的平铺项目页面。用户可以像在寻呼机中一样水平滚动各个部分,而页面不垂直滚动。此外,在屏幕顶部,用户有可点击的标签,按标题显示所有可用部分。在 android 上,我通过创建嵌套的 RecyclerViews(一个 lvl 用于部分,一个用于图块)来实现这一点,并结合 DiffUtil 进行快速内容更新。我对 iOS 开发完全陌生,但我想创建类似的东西。在深入了解基本组件之后,它看起来像 UICollectionView 可能是最合适的。在我的应用程序中,我尝试使用 RxSwift 和 RxDataSource 使用 MVVM 方法。最后一个支持分段 UICollectionView,我想知道是否有可能通过使用单个 UICollectionView 创建整个视图。部分会水平滚动,每个部分都会包含网格元素?或者也许我可以将一个 RxDataSource 嵌套在另一个中。或者也许我不能为此使用 RxDataSource,我应该尝试其他方法。为了弄清楚我在说什么,我包括图片

我将非常感谢任何建议,因为我无法找到任何有用的东西。

0 投票
1 回答
460 浏览

ios - RxDataSources `Generic parameter 'Self' could not be inferred`

I know there are a lot of questions about this, I looked at all of them but it doesn't fix my problem. I also commented on one of them but the question doesn't seem to be active anymore so I don't expect an answer there.

I'm trying to implement RxDataSources. See my code below:

And the ViewController:

I get Generic parameter 'Self' could not be inferred on .bind(to: self.rxTableView.rx.items(dataSource: dataSource)). I looked at the RxDataSources examples and seem to have it the same now, but I can't seem to fix this error.

Any ideas?

0 投票
2 回答
4297 浏览

ios - RxDataSources tableView 具有来自一个 API 源的多个部分

目前对于我们的 API 请求,我们使用 Rx。我们如何使用它的一个例子是:

shopId这将获取所有状态为给定的订单.active。每次更新时,都会替换本地orders对象并重新加载 tableView。

这会重新加载我们想要避免的整个 tableView。我现在正在研究 RxDataSources 但无法真正弄清楚如何使其正常工作。

一个Order对象有另一个属性currentStatus,它可以是 3 个不同的值。我们拥有的是一个包含 3 个不同部分的 tableView,每个部分显示一个currentStatus.

这应该如何在 RxDataSources 中实现?理想情况下,将它绑定到我之前展示的服务(OrderRxService.....subscribe()..)。

我现在要设置 RxDataSources 类型的是:

我试图让它发挥作用的是:

可能有不同的方面可以改进。例如,Variable<[Order]>我想成为公正[Order]。而不是让这个可观察的,可以完全跳过它并通过观察我们的 OrderRxService 创建三个不同的部分吗?

是否有可能拥有类似的东西:

谢谢你的帮助!

0 投票
1 回答
1041 浏览

ios - RxSwift 如何知道 TableView 重新加载结束

我想知道 reloadTableView 的结尾然后我想向下滚动到表格视图的底部。

在我使用之前RxSwift 刚刚之后reloadData 可以使用setContentOffSetor ScrollToRow

我用找到的代码试了一下。从来没有打电话endUpdates

0 投票
2 回答
543 浏览

swift - 如何处理两个表视图关联?

我是一个新的 Swifter,这是我新公司的代码。

使用 RxSwift,使用 RxDataSource,如何处理两个表视图关联?

左边tableView的cell被点击了,右边tableView的数据随之变化。

通过中间状态变量组织右表视图的数据。

坏代码的味道。</p>

这是图像

一

代码如下:</p>

private var lastIndex : NSInteger = 0, 用于比较左表视图的新旧选定索引,让右表视图启动,currentIndex如果不同

被使用了self.currentSelectIndexPath,因为当左 tableView 的最后一个单元格被点击时,UI 逻辑是不同的。

self.currentListData用于捕获右表视图的当前数据,当左表视图单击不同的行时。

self.currentListData也用于UITableViewDelegate.

如何改进代码?

如何消除中间状态的变量。

对应的模型是

0 投票
1 回答
495 浏览

rx-swift - RxSwift MVVM 表视图/集合视图,用户输入单元表示状态

我对你们中的任何人有一个要求。我想创建在单元格中有用户输入的 collectionview/tableview。来自这些输入的值的混合将代表状态。我想观察该状态,如果满足某些条件,我想重新创建所有单元格。我创建了非常简单的应用程序,在其中演示了我如何尝试实现它,但是我收到了重入警告,我很想了解您的想法/最佳实践。这是您可以结帐的回购。

https://github.com/beretis/CollectionViewTest

PS:我使用 RxData 源,我很想知道是什么导致了这种重入(我有我的想法)

0 投票
2 回答
117 浏览

swift - 尝试在 RxSwift 中将输出绑定到我的 tableviewCell UI 元素

我有一个存在于我的 VM 中的输出,并且基于一些更改,我希望驻留在我的自定义 tableviewCell 中的文本字段以某种方式更改。我不确定如何将位于 tableviewcell 中的 UItextfield 绑定到我的输出。