-
Notifications
You must be signed in to change notification settings - Fork 3k
getConfig #295
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
getConfig #295
Conversation
This looks good to me and I think will help many people. For docs, after this PR was merged, whoever merges it should create a new issue called "Docs for #295" and assign to me. |
The implementation seems fine, but I am hugely not a fan of overly verbose method names. I really think |
@nateabele That works for me too. |
To demonstrate what the different suggestions would look like: var url = $state.get('foo').url; getStateConfig var url = $state.getStateConfig('foo').url; In my opinion, a method name should always hint at the parameters it is expecting and what it is returning. That is what I favor a slightly longer method name over just That being said, I'm of course going to follow the project's teams' consensus. |
Isn't the var url = $state.getConfig('foo').url; We could then return the config of the current state by default, and use |
I like getConfig() with optional parameter. |
This is redundant, given |
It's just a convenience thing. I mean of course it's redundant*, but maybe it's not a bad idea to have an intuitive fallback. *It's not even the same thing because getConfig returns a copy, rather than the actual object. |
I have to disagree with @nateabele for two reasons. First, it would be a very confusing API if we told developers they could read config for any state using Second, it's not just semantically different, but also a different object in memory. I could be mistaken, but by looking at the code it seems to me that All in all, I'm strongly in favor of having a unified, easily understandable API. |
One person's intuitive fallback hides another person's bug. :-) |
What's preventing you from passing the name of the current state? If you actually want the current state, you'd only ever use I'm not sure why this idea is so confusing. |
I understand your point, @nateabele, but I just happen to have the contrary opinion. The code is tested and provides a copy of the config object. This is the purpose of the method. How do you handle disagreements on this project? |
Generally, it's been informal consensus among the main developers/contributors, which so far hasn't been terribly hard to reach. One of the main developers recently had a kid (and so has been pretty unavailable), and his style is to favor explicitness even more than I normally would, which is what I'm representing here.
Okay, great. Recommend that they always pass it a parameter.
That's actually not ever what we want, so maybe the correct approach for the sake of consistency is to ensure that |
Yeah I'm quite suprised to learn that $state.current is not a copy. @davidpfahler don't worry about the arguing, we do it over everything :). You should mainly know that your contribution is much appreciated and thank you for helping. For now let's just do |
@davidpfahler Upon further reflection, here's why what you're suggesting is not line with the goals of the project. Basically, |
@nateabele That makes more sense to me now. I think this was a healthy discussion showing some general problems in the API (like |
I'm a bit late in the discussion, but what's the use case for returning copies of states? $state.current is not a copy on purpose, so that you compare it by identity to the original object you passed in, e.g. Personally I think it would be fine to have |
Okay fair enough. :-) I have some other work to do here tomorrow anyway, so I'll patch it then. @timkindberg Can you update the documentation accordingly? |
Yup just make an issue and assign to me if u dont mind. |
Oh fuck it. I'll just do it now. |
K done. Only in API. |
EDIT: Method name changed to
getConfig
.Don't be confused by the branch name, method is now called
getStateConfig
as mentioned by @timkindberg.Not sure how or where to do docs.
Fixes #294.