2014-01-29 63 views
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); } 
     } 
} 

回答

0

嗯,這應該工作,我懷疑在ReactiveList一個錯字。想爲它創建一個測試用例嗎?

+0

肯定 - 會做。我可能不得不首先針對所有項目建立一些問題。我渴望參與其中。 –

+0

建立ReactiveUI.sln,不要擔心其他的,這應該是所有的Windows友好的 –

相關問題