说我有一个类型T:
class T {
public int identifier; //Arbitrary but unique for each character (Guids in real-life)
public char character; //In real life not a char, but I chose char here for easy demo purposes
}
Run Code Online (Sandbox Code Playgroud)
我有一个预定义的有序标识符序列:
int[] identifierSequence = new int[]{
9, 3, 4, 4, 7
};
Run Code Online (Sandbox Code Playgroud)
我现在需要订购IObservable<T>产生以下对象序列的an :
{identifier: 3, character 'e'},
{identifier: 9, character 'h'},
{identifier: 4, character 'l'},
{identifier: 4, character 'l'},
{identifier: 7, character 'o'}
Run Code Online (Sandbox Code Playgroud)
使生成的 IObservable 产生hello. 我不想使用 ToArray,因为我想在对象到达时立即接收它们,而不是等到所有内容都被观察到。更具体地说,我希望像这样接收它们: …
我目前正在研究java me应用程序,我有这个代码:
svgForm.setSVGEventListener(new SVGEventListener(){
public void keyPressed(int i) {
System.out.println("Val"+i);
}
public void keyReleased(int i) {
System.out.println("Val"+i);
}
public void pointerPressed(int i, int i1) {
return;
}
public void pointerReleased(int i, int i1) {
return;
}
public void hideNotify() {
return;
}
public void showNotify() {
return;
}
public void sizeChanged(int i, int i1) {
return;
}
});
Run Code Online (Sandbox Code Playgroud)
但是,如您所见,我不需要覆盖所有方法.更糟糕的是,通过覆盖它们我失去了功能.有没有办法保留原始方法,只覆盖某些方法?
在 ReactiveUI 9 中,ReactiveList已弃用 DynamicData(博客文章)。我目前正在尝试更新我的代码以使用SourceList. 我能够让 ViewModel 工作,但是SourceList在 WPF 中用作绑定数据源似乎并不容易。
我的第一次尝试是创建绑定,就像在以前版本的 ReactiveUI 中所做的那样:
this.OneWayBind(ViewModel, vm => vm.MyList, v => v.MyListView.ItemsSource);
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为SourceList不可枚举(无法将 DynamicData.ISourceList 转换为 System.Collections.IEnumerable)
我的第二次尝试是使用Items列表的属性。
this.OneWayBind(ViewModel, vm => vm.MyList.Items, v => v.MyListView.ItemsSource);
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为Itemsgetter 在内部创建了列表的副本,这意味着列表中的更改不会反映在视图中。
我的第三次尝试是使用该Bind方法创建一个ReadOnlyObservableCollection. 我不想在视图模型中执行此操作,因为那样我将不得不为每个视图模型中的每个列表添加第二个列表属性,这会扰乱我的代码,违反 DRY 原则。此外,要绑定到的列表类型取决于所使用的视图框架。(例如:WinForms 使用BindingList代替)
此外,我的视图的视图模型可能会更改,这意味着在设置新视图模型时必须清理和替换生成的绑定和列表。这给了我以下片段:
this.WhenAnyValue(v => v.ViewModel.VisibleInputs)
.Select(l =>
{
var disposer = l.Connect().Bind(out var list).Subscribe();
return (List: list, Disposer: disposer);
})
.PairWithPreviousValue()
.Do(p …Run Code Online (Sandbox Code Playgroud) .net ×1
c# ×1
data-binding ×1
dynamic-data ×1
java ×1
methods ×1
overriding ×1
reactiveui ×1
sorting ×1
wpf ×1