New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Val.filer contains null if predicate is false #63
Comments
As a workaround, I do not use filter but replace values that do not satisfy the predicate with the previous value. This is then not forwarded as a change by the Var. |
Hi, yes, holding
Returning the previous value doesn't work when there is no previous value. In your case, that would be when the initial value of the If you are not interested in calling EventStreams.valuesOf(this.textField.textProperty()).filterMap(s => toLocalDateTime(s)) where |
Hi, this is similar to what I came up with. I am using an EventStreams.nonNullValues created from the Val's values() function. Your solution is much easier, so I think I am going to change my code. |
I must say the reactfx's behavior with nulls can be quite confusing, especially when For example, consider two properties A and B, either of which can be null. When I do:
The combine function will not be called at all if either A or B contains null, even if an invalidation occured on the other property. Same for:
The only one that works as desired is:
Trying to change A and B to not use The only other option was something ugly like:
Atleast I'm happy enough with the |
Hi,
I am using a Val bound to the text property of a TextField. I filter out strings which cannot be converted to LocalDateTime with a predicate in the string formatter
Val.filter(this.textField.textProperty(), this.format::isValidDateTime)
and them map the Val to LocalDateTime. In my program I start observing null values in the the Val when the isValidDateTime returns false. From the documentation of Val.filter, I would expect that values that do not satisfy the predicate are dropped and not replaced with null. However, I am not sure because I did not find a definition for an empty Val. Here is the code with the javadoc from
It is obvious that values failing the predicate are substituted by null. Is that how it is supposed to work?
The text was updated successfully, but these errors were encountered: