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

GetValue return type #168

Open
miniscruff opened this issue Mar 17, 2024 · 4 comments
Open

GetValue return type #168

miniscruff opened this issue Mar 17, 2024 · 4 comments
Labels
question Further information is requested select

Comments

@miniscruff
Copy link

miniscruff commented Mar 17, 2024

I was playing around with huh and on the select input type there is a get value function and I am wondering why it returns any and not T/*T.

This func specifically

huh/field_select.go

Lines 542 to 545 in 71f31c1

// GetValue returns the value of the field.
func (s *Select[T]) GetValue() any {
return *s.value
}

Should this be?

// GetValue returns the value of the field.
func (s *Select[T]) GetValue() T {
	return *s.value
}

Or as a pointer.

// GetValue returns the value of the field.
func (s *Select[T]) GetValue() *T {
	return s.value
}

This may affect other input types, I did not really check. I can definitely contribute as well if a change like this makes sense. ( May break compatibility so not sure )

@maaslalani
Copy link
Contributor

Hey @miniscruff, I believe this makes sense! However, we'll have to double check that this does not break the Bubble Tea examples as they rely on the GetValue to populate the values in the form which is an interface method on Field.

@miniscruff
Copy link
Author

Hey @miniscruff, I believe this makes sense! However, we'll have to double check that this does not break the Bubble Tea examples as they rely on the GetValue to populate the values in the form which is an interface method on Field.

For sure it would be a change to the interface, even if beneficial it would probably be breaking something. If you think its worth it I can make a PR and look around for anything that breaks in this repo. If not, no worries.

@reavessm
Copy link

I came here to make the same suggestion. Let me know if you'd like any help testing

@maaslalani
Copy link
Contributor

@reavessm GetValue is an interface method but since it expects any I think using the generic will still satisfy it. Would love to double check that doesn't break anything for bubble tea examples and we can make the change!

@caarlos0 caarlos0 added question Further information is requested select labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested select
Projects
None yet
Development

No branches or pull requests

4 participants