Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
Command (mark with an
x)Description
A clear and concise description of the problem or missing capability...When sticking to the smart/dumb(presentational) components paradigm, user has no option to precisely control the implementation of lifecyclehooks in the generated TS code. Given that the default is
implements OnInit, this leads to unnecessary post-editing (removingOnInit, or adding other hooks by hand). As you gain experience in angular, you are able to tell beforehand which hooks you're gonna need before you issueng g c, but the CLI doesn't give you a way to fine-tune the generated code at the command level.Describe the solution you'd like
If you have a solution in mind, please describe it.Introduce
--hooksflag, taking a piped string of hooks to implement, or a specific constant to include none. Examples:ng g c mycomp --hooks none=ng g c mycomp -hng g c mycomp --hooks OnInit|OnDestroy|AfterViewInitPros:
--skip*model which presumes existing defaults)ng g s myserv --hooks OnDestroy)Cons:
Having a flag to control the
implementspart would allow user to create custom scripts to follow the smart/dumb paradigm in their workflow, such as:Describe alternatives you've considered
Have you considered any alternative solutions or workarounds?I would gladly hear of one if exists.
Of course, the suggested flag
--hooks(alias-h) is just an example - you might choose a different wording, such as--implements, howeverimplementscould suggest that user's custom or 3rd party interfaces/classes could be implemented too, while the option we discuss pertains to Angular lifecycle hooks onlyA fast-track solution would be to provide
--skipOnInitflag, but this is a non-scalable solution which I don't want to promote here.