Getting prior value on change of property using ReactiveUI in WPF MVVM

How about this:

 this.WhenAnyValue(vm => vm.AccountHolderType)
      .Buffer(2, 1)
      .Select(b => (Previous: b[0], Current: b[1]))
      .Subscribe(t => { 
//Logic using previous and new value for AccountHolderType 
});

I think you have missed this straight forward Buffer function.


Something like:

var previousValue = this.WhenAnyValue(vm => vm.AccountHolderType);
var currentValue = previousValue.Skip(1);
var previousWithCurrent = 
  previousValue.Zip(currentValue, (prev, curr) => { /* DO SOMETHING HERE */ });

Tags:

C#

Wpf

Reactiveui