You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be great to support unpacking or destructured objects for function parameters.
Working on a PR here with update to the readme.
// destructured object parameter wont require any annotations. functioncreateEngine({power}){ ... }//then in module config can take the simple route as well since function params are parsed and $inject is automatically addedconstcarModule={engine: ['factory',createEngine],power: ['value',{horses: 400}]};
Let me know what you think. Would this be something your interested in merging in. Plan on finishing tests today and will convert PR off draft once done.
Great project, thanks.
The text was updated successfully, but these errors were encountered:
PR is updated. Will push more if we discover more issues in out testing. my REGEX kungfu is not so great. I am certain there is a better way to parse the parameters to slim is down a bit than what I did, but its working.
It will add about only about 0.4k to the minified size, and a negligible increase to the gzip size, to enable a very powerful and flexible design pattern. albiet: the RORO design pattern is great but itself adds some weight if size is crucial since the minification process does not mess with the object property names. so the functions parameter destructuring gets kept. Makes it great for injection with DIDI though.
Looks like something that could be worth supporting, especially as it would make generating typings very powerful (TS setup that is):
import{InjectionContext}from'../types';functionCar({ power } : InjectionContext){
...
}
However, whatever we support should work without major caveats, and shall be properly tested. I'd be afraid that it would take quite some regex-ninja to get instantiation right (and I don't want to add a JS ast-parser to this library).
A couple of examples:
// inject `power as foobar`functionCar({power: foobar}){// access `power` as `foobar`}// default value for powerfunctionCar({
power =1000}){// if power is not provided, default to 1000}// interaction with existing patternsfunctionCar({
power =1000}){// if power is not provided, default to 1000}Car.$inject=['config.car'];
Would be great to support unpacking or destructured objects for function parameters.
Working on a PR here with update to the readme.
Let me know what you think. Would this be something your interested in merging in. Plan on finishing tests today and will convert PR off draft once done.
Great project, thanks.
The text was updated successfully, but these errors were encountered: