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

Add .defaultValue and .isDefaultValue to @Default #76

Merged
merged 3 commits into from
Jun 18, 2021
Merged

Conversation

sindresorhus
Copy link
Owner

I need it to disable an input the value matches the default value. This is what I'm currently using:

.disabled(textSize == Defaults.Keys.textSize.defaultValue)

@sindresorhus
Copy link
Owner Author

I wonder if it also makes sense to add .isDefaultValue for convenience.

@hank121314
Copy link
Collaborator

I wonder if it also makes sense to add .isDefaultValue for convenience.

Yeah! It will be great if we have .isDefaultValue 😄.
But Defaults.Serializable is not Equatable, we should document that only Value conforms to Defaults.Serializable & Equatable can use .isDefaultValue.

@sindresorhus
Copy link
Owner Author

we should document that only Value conforms to Defaults.Serializable & Equatable can use .isDefaultValue.

I think that's made clear through the type signature.

@sindresorhus sindresorhus changed the title Add .defaultValue to @Default Add .defaultValue and .isDefaultValue to @Default Jun 17, 2021
@sindresorhus sindresorhus merged commit 6e42795 into main Jun 18, 2021
@sindresorhus sindresorhus deleted the default-value branch June 18, 2021 06:15
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.

None yet

2 participants