Skip to content
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

Merged
merged 3 commits into from
Feb 28, 2025

Conversation

andydotxyz
Copy link
Member

@andydotxyz andydotxyz commented Feb 27, 2025

This has annoyed me for a while that it was missing!

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.
  • Public APIs match existing style and have Since: line.

@coveralls
Copy link

coveralls commented Feb 27, 2025

Coverage Status

coverage: 62.286% (-0.09%) from 62.372%
when pulling 8b756d7 on andydotxyz:feature/bindpreferencelists
into e471a5a on fyne-io:develop.

Copy link
Member

@Jacalz Jacalz left a 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,
Copy link
Member

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.

Copy link
Member Author

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 {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 👍

@andydotxyz andydotxyz merged commit b1d24d2 into fyne-io:develop Feb 28, 2025
11 checks passed
@andydotxyz andydotxyz deleted the feature/bindpreferencelists branch February 28, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants