I'm using .Skip(1) a lot to avoid unwanted values during initialization, am I doing it wrong? #3115
Unanswered
bonzaiferroni
asked this question in
Q&A
Replies: 3 comments
-
Yes I also have the first value either being the default value or null during initialization. I either filter / check for null or use |
Beta Was this translation helpful? Give feedback.
0 replies
-
WhenAnyValue will emit the current value always unless you have A skip(1). So if it is null you'll get a null emission straight away. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is one disadvantage of Fody, if you did it the non-Fody way, you could just initialize the backing field string _SomeBackingField = "My First Value";
public SomeBackingField {
get => _SomeBackingField;
set => this.RaiseAndSetIfChanged(...);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've had several bugs that came down to values emitted during initialization that shouldn't be emitted. For example, a variable with the
[Reactive]
attribute that is subscribed to usingthis.WhenAnyValue(x => x.MyProperty)
(I'm usingReactiveUI.Fody
). In many cases the first value is actually not valid so each subscriber must use.Skip(1)
. Is that the correct way to handle it or is there a better way?Beta Was this translation helpful? Give feedback.
All reactions