-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Provider should have a filter method #19981
Comments
This is one more case where |
What's the expectation here?
Is |
I think it should behave the same as val someValue: Property<Int>
someValue.convention(5)
val even = someValue.map { it * 2 }
// ... somewhere else
someValue.set(4) I don't know from the top of my head how this would behave. I think even will have the value 8, am I right? |
Right, I could go along with that. In your example, I was asking because You can get close to what you're looking for with
Only I think we'd need to think more about how a |
I assume you mean the APIs should be similar and not that providers should be eager, right? |
That doesn't sound dissimilar to the situation with There were talks of introducing a sort of conditional dependency (a task / work dependency that would only be activated at the last possible moment when a particular condition holds). |
Yes. |
Yes, but the difference here is that you can stop once you have a producer with a value. The dependency comes from
The dependency needs to be... both?
Maybe it's a source of footguns to have the presence of a Provider be based on the value of the Provider. I'm trying to think of a good use case where this would be helpful... Say you have three locations for a configuration file:
You could have a property (pseudo):
But this is missing the fallback to the other locations. So you could do...
Or with
I think the simplest thing is actually:
But you need to somehow record that the non-existence of some files is an input then. |
Having a filter method would also be one way to solve: #12388 I think it would be a better way than to use |
Using this extension function in the absence of native support:
|
FTR, once we migrate more to providers I expect more code that requires filtering like this, so delivering this feature is kind of a pre-requisite of the migration. |
Fixes #19981 ### Reviewing cheatsheet Before merging the PR, comments starting with - ❌ ❓**must** be fixed - 🤔 💅 **should** be fixed - 💭 **may** be fixed - 🎉 celebrate happy things Co-authored-by: Vlad Chesnokov <vchesnokov@gradle.com>
Fixes #19981 ### Reviewing cheatsheet Before merging the PR, comments starting with - ❌ ❓**must** be fixed - 🤔 💅 **should** be fixed - 💭 **may** be fixed - 🎉 celebrate happy things Co-authored-by: Vlad Chesnokov <vchesnokov@gradle.com>
Fixes #19981 ### Reviewing cheatsheet Before merging the PR, comments starting with - ❌ ❓**must** be fixed - 🤔 💅 **should** be fixed - 💭 **may** be fixed - 🎉 celebrate happy things Co-authored-by: Vlad Chesnokov <vchesnokov@gradle.com>
Fixes #19981 ### Reviewing cheatsheet Before merging the PR, comments starting with - ❌ ❓**must** be fixed - 🤔 💅 **should** be fixed - 💭 **may** be fixed - 🎉 celebrate happy things Co-authored-by: Vlad Chesnokov <vchesnokov@gradle.com>
…d of Predicate ### Context It was missed during the [original PR](#26067) for * #19981 Reported by @lacasseio from the Nokee project. ### Reviewing cheatsheet Before merging the PR, comments starting with - ❌ ❓**must** be fixed - 🤔 💅 **should** be fixed - 💭 **may** be fixed - 🎉 celebrate happy things Co-authored-by: Vlad Chesnokov <vchesnokov@gradle.com>
Expected Behavior
When dealing with a provider, I sometimes want to only use it's value if it fits a certain criteria.
Current Behavior
Feature is missing
Context
I was dealing with a Provider of a list of things and I only wanted to use it in case the list contains some elements and otherwise use
getOrElse
to provide some default value. This is currently not easily possible due to the missing filter method.The text was updated successfully, but these errors were encountered: