-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Feature/bindpreferencelists #5565
Feature/bindpreferencelists #5565
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Nice one. Just a few questions/suggestions inline.
|
||
type internalPrefs = interface{ WriteValues(func(map[string]any)) } | ||
|
||
func bindPreferenceListComparable[T bool | float64 | int | string](key string, p fyne.Preferences, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are to be consistent with the other functions here, the one called "comparable" should just pass a hard-coded func(T, T) bool
into the function without the "comparable" suffix. Doing the same here would avoid the code duplication of all the comparison functions you have above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch thanks.
// Changes to this value will be saved to application storage and when the app starts the previous values will be read. | ||
// | ||
// Since: 2.6 | ||
func BindPreferenceBoolList(key string, p fyne.Preferences) BoolList { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really fill the API with new functions for each type? We could do a single BindPreferenceList[T bool | float64 | int | string]()
and potentially expand that typeset in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See note in slack, we might even be able to just do [T comparable]
and match all comparable types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather complete the API as it exists already (as it was basically missing). We could have a generic version but as I doubt other items will be added in the future I don't think it would be pertinent to add a new pattern for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I kind of agree. In general, I think we should focus on using generics now in these cases where it makes a lot of sense over flooding the API surface with a bunch of new functions but like you say, it should have been there from the start. Will approve 👍
This has annoyed me for a while that it was missing!
Checklist: