我正在尝试从ReactiveList中压缩两个序列,以便在更改内容时返回旧值和新值。但是,压缩订阅似乎返回了“旧的和新的”相同的值。
我错过了什么?
谢谢: - )
void Main()
{
var names = new string[] {"Bill","Jane","Tom", "Jess"};
var list = new ReactiveList<ReactivePerson>(){ChangeTrackingEnabled = true};
// These subscriptions work as expected
list.ItemChanging.Subscribe(x=> string.Format("Property {0} changing from {1}",x.PropertyName, x.GetValue()).Dump());
list.ItemChanged.Subscribe(x=> string.Format("Property {0} changed to {1}",x.PropertyName, x.GetValue()).Dump());
// This subscription doesn't. It is returning the same value for both 'old and new'
list.ItemChanging.Zip(list.ItemChanged, (oldrec, newrec)=>new{o=oldrec.GetValue(),n=newrec.GetValue()}).Subscribe(x=>x.Dump());
// Add records
list.AddRange(names.Select (n => new ReactivePerson{FirstName=n}));
// manipulate records
list[0].FirstName = "Terry";
}
public class ReactivePerson : ReactiveObject
{
string _firstName;
public string FirstName{
get { return _firstName; }
set { this.RaiseAndSetIfChanged(ref _firstName, value); }
}
}
答案 0 :(得分:0)
嗯,这应该有效,我怀疑ReactiveList中有拼写错误。想为它创建一个测试用例吗?