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

Default Option Values Support #10

Closed
wants to merge 1 commit into from
Closed

Conversation

ghost
Copy link

@ghost ghost commented Aug 22, 2017

@benhutton This is one potential solution to address Issue #5. This is not originally what I was going to go with, but I think it provides a relatively straight forward solution that will be easy to build on and add support for #2.

Another approach would be to simply except Component developers to have their action method insert default values, but I'm guessing that is not what @desiringgod/frontend is looking for.

@ghost ghost assigned benhutton Aug 22, 2017
@ghost ghost requested review from benhutton, scottcorgan and shanebo August 22, 2017 18:06
@ghost
Copy link
Author

ghost commented Aug 22, 2017

@scottcorgan @shanebo Check out the example implementation here:

option :some_option, default: 'default value'

@benhutton
Copy link
Member

@joeosburn-desiringgod how do you see required options (#2) fitting into this API?

@ghost
Copy link
Author

ghost commented Aug 22, 2017

@benhutton

option :my_option, { default: 'default value', required: true }

@benhutton
Copy link
Member

@joeosburn-desiringgod wouldn't default and required be mutually exclusive keys? (In keyword arguments, that's how it works.)

@ghost
Copy link
Author

ghost commented Aug 22, 2017

@benhutton Yes, but I'd still leave the api like this.

@shanebo shanebo assigned ghost and unassigned benhutton Aug 22, 2017
@scottcorgan
Copy link

@joeosburn-desiringgod I like the API for required. Could you do a check and throw an error if both default and required are used?

@scottcorgan
Copy link

@joeosburn-desiringgod I'm all about throwing errors so we know exactly the mistake we made. Makes for low cognitive load 👍

@shanebo
Copy link

shanebo commented Aug 22, 2017

@joeosburn-desiringgod @benhutton @scottcorgan

I'm trying to think through when we'd ever have a required key that doesn't have a default value. Also if we didn't pass in a required key, wouldn't it throw anyway? If so, why bloat the component code to cover something that will already error out? Is it only to get cleaner error messages?

@scottcorgan
Copy link

@shanebo a required option would never have a default value, because it's required. An error should be thrown if that option is not given to the component. Default values are for options that are, sigh, optional.

Which, @joeosburn-desiringgod, begs the question, maybe option isn't the right word for these since some would be optional and some would be required. attributes or properties line up more with front-end terminology 👍

@ghost ghost force-pushed the feature/default-options branch 2 times, most recently from a3c881a to 62df8e4 Compare September 6, 2017 14:54
@ghost ghost force-pushed the feature/default-options branch from 62df8e4 to dbc30ad Compare September 6, 2017 14:56
@ghost ghost mentioned this pull request Sep 11, 2017
@ghost
Copy link
Author

ghost commented Sep 11, 2017

Closing in favor of #20

@ghost ghost closed this Sep 11, 2017
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants