Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Why isn't the ngFactory coupled to the Component's class? #1982

Open
jodinathan opened this issue Nov 3, 2021 · 0 comments
Open

Why isn't the ngFactory coupled to the Component's class? #1982

jodinathan opened this issue Nov 3, 2021 · 0 comments

Comments

@jodinathan
Copy link

Hello,

Thanks for the hard work with Angular!
We really like this project.

We have an internal (for now) version of Angular that has some tweaks and we will start migrating to Angular 7 and NNBD soon. As we do that we thought in making the components tightly coupled to the generated code. Basically, instead of generating stuff into .dart_tool we would make it generate the code in the same folder as the class and make the class extend the generated code. Pretty much like any other source generator package out there.

By letting the template directly use the class file through part of binding we aim to:

  • Remove exportAs.
  • Let the template use private stuff.
  • Make the generated class expose common things like the NgFactory and changeDetectionRef.markForCheck
  • Add methods to aid debugging
  • Comment the generated code with info so the dev can have a better understanding of what is happening
  • Allow implicit injection by making the original authored class only declare a getter.
    Example: abstract class MyComponent extends _Ng { ParentComponent get parent; }
    Would make the generated class have the parent property without having to use the constructor. Reasoning: We had a hard time refactoring components because the base class needed additional injections.

However, before we dig into that, we would like to know if you could please share info that could make we not follow that path or any suggestions/info at all.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant