0
我想壓縮來自ReactiveList的兩個序列,以便在某些更改時返回舊值和新值。然而,壓縮的訂閱似乎返回了「新舊」的相同值。Trouble Zipping ReactiveList <T> .ItemChanging與ReactiveList <T> .ItemChanged
我錯過了什麼?
感謝:-)
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); }
}
}
肯定 - 會做。我可能不得不首先針對所有項目建立一些問題。我渴望參與其中。 –
建立ReactiveUI.sln,不要擔心其他的,這應該是所有的Windows友好的 –