如果术语关闭,请道歉;我是一名 iOS 开发人员,必须使用 Xamarin.iOS 来开发应用程序。我正在使用带有 DynamicData 和 MVVM 架构的 ReactiveUI。总的来说,我对 RxSwift 和 FRP 概念相当满意。SourceList<MyThing>
根据文档,我有一个发布 a 的模型,如下所示:
// Property declarations
private readonly SourceList<MyThing> Things;
public IObservableCollection<MyThing> ThingsBindable { get; }
// Later, in the constructor...
Things = new SourceList<MyThing>();
// Is this of the right type?
ThingsBindable = new ObservableCollectionExtended<MyThing>();
Things
.Connect()
.Bind(ThingsBindable)
.Subscribe();
我可以.BindTo()
在我的视图(即 iOS 领域的 ViewController)中成功使用来获取 UITableView 以在模型更改时进行更新:
Model
.WhenAnyValue(model => model.ThingsBindable)
.BindTo<MyThing, MyThingTableViewCell>(
tableView,
new NSString("ThingCellIdentifier"),
46, // Cell height
cell => cell.Initialize());
我不想直接绑定到模型,而是让 ViewModel 订阅和发布(或以其他方式代理)这个SourceList<MyThing>
,或者这个的可绑定版本,以便 View 只使用 ViewModel 属性。在文档SourceList
中声明private
;我不确定这里的最佳实践:我是否将其公开并Connect()
在 ViewModel 中执行?或者有没有办法传递IObservableCollection<MyThing> ThingsBindable
从 ViewModel 公开暴露的内容?我也不相信这ObservableCollectionExtended<MyThing>
是 Bindable 属性的正确类型,但它似乎有效。
我尝试了,等的各种组合.ToProperty()
,并在 ViewModel 中制作了 View-binding Observable 的一个版本,但无济于事,现在我只是将自动完成功能扔到墙上,看看有什么效果。任何方向表示赞赏。TIA。.Bind()
.Publish()