Using ReactiveUI, is it possible to ignore the initial value for a given ReactiveObject?
For example, I have a ViewModel I initialize, and then I WhenAnyValue on the ViewModel. I get notified immediately that the value is null for my chosen property. Yes, I could .Where(x => x != null) to avoid this, but it's potentially possible that knowing it's null later is of value.
In other words, I want to start getting notifications after the 1st change in the value.
I'm not readily seeing how I can do this or if it's even possible. I see references to Initial Value in the source for WantsAnyValue/WantsAny but it's unclear to me how I set that initial value.
Moving my comment to an answer on request of OP for points ;)
To ignore the first OnNext at init.
this.WhenAnyValue( model => model.Field ).Skip( 1 )
You should use ObservableForProperty in this case.
WhenAnyValue will immediately notify about the initial value to the subscriber plus any new values in the future while ObservableForProperty only notifies about new values and skips the initial value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With