0

I am trying to zip two sequences from a ReactiveList to return the old and new values when something changes. The zipped subscription however appears to be returning the same value for 'old and new'.

What am I missing?

Thanks :-)

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); }
        }
}
Damien Sawyer
  • 5,323
  • 3
  • 44
  • 56

1 Answers1

0

Hm, this should work, I suspect a typo in ReactiveList. Want to create a test case for it?

Ana Betts
  • 73,868
  • 16
  • 141
  • 209
  • sure - will do. I might have to run some questions by you about building all the projects first. I'm keen to get involved though. – Damien Sawyer Jan 30 '14 at 06:03
  • Build ReactiveUI.sln, don't worry about the other ones, that should be all the Windows-friendly ones – Ana Betts Jan 30 '14 at 06:14