In PR #41 I talked about simplifying the signatures of several methods in js.go but rejected that as I thought it would be a breaking change. Since then, I've realized that because the first parameter is the same type as the second variadic parameter, the change is not in fact breaking and simplifies the signature of the end-user API.
I'd suggest that the following three method signatures be changed below:
- From
Get(name string, path ...string) to Get(name ...string
- From
Class(class string, path ...string) to Class(class ...string)
- From
(v Value) Get(name string, path ...string) to (v Value) Get(name ...string)
The change to the Class method slightly simplifies the key generation but otherwise the code is pretty much the same. The main benefit is that, having a single parameter, it makes more sense when a nested class is specified. Consider Class("mdc", "chips", "MDCChipSet") as described in my previous example - with the original signature, the class parameter would contain mdc but the actual class (MDCChipSet) being loaded would be the second element of the path slice. With the revised signature, the elements make sense in the order they're provided.
I do realize this is a completely cosmetic change but wanted to present the idea prior to the library reaching 1.0. If it sounds reasonable, I've got a branch I used to test that this could be done simply - assign this to me and I'll clean up that branch and submit a PR.
In PR #41 I talked about simplifying the signatures of several methods in
js.gobut rejected that as I thought it would be a breaking change. Since then, I've realized that because the first parameter is the same type as the second variadic parameter, the change is not in fact breaking and simplifies the signature of the end-user API.I'd suggest that the following three method signatures be changed below:
Get(name string, path ...string)toGet(name ...stringClass(class string, path ...string)toClass(class ...string)(v Value) Get(name string, path ...string)to(v Value) Get(name ...string)The change to the
Classmethod slightly simplifies the key generation but otherwise the code is pretty much the same. The main benefit is that, having a single parameter, it makes more sense when a nested class is specified. ConsiderClass("mdc", "chips", "MDCChipSet")as described in my previous example - with the original signature, theclassparameter would contain mdc but the actual class (MDCChipSet) being loaded would be the second element of thepathslice. With the revised signature, the elements make sense in the order they're provided.I do realize this is a completely cosmetic change but wanted to present the idea prior to the library reaching 1.0. If it sounds reasonable, I've got a branch I used to test that this could be done simply - assign this to me and I'll clean up that branch and submit a PR.