-
Notifications
You must be signed in to change notification settings - Fork 3
refactor: migrate from constructor based injection to inject function
#496
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
base: main
Are you sure you want to change the base?
Conversation
| constructor( | ||
| private appStateService: AppStateService, | ||
| private dataRepoService: DataRepositoryService, | ||
| private logger: Logger, @Inject(LOCALE_ID) private localeId: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hier ist tatsächlich ein Fall, wo Konstruktor basierte Injektion problematisch war. localeId wird gar nicht mehr verwendet und kann somit gestrichen werden. Meine IDE hat das zumindest vor dem Refactoring nicht angezeigt. Nach dem Refactoring schon.
|
Kannst du einmal die Konflikte beheben? |
| private min = inject(new HostAttributeToken('minLength')); | ||
|
|
||
| validator: Function; | ||
|
|
||
| constructor(@Attribute('minLength') private min: number) { | ||
| this.validator = minLengthArrayValidator(min); | ||
| constructor() { | ||
| const min = this.min; | ||
|
|
||
| this.validator = minLengthArrayValidator(Number(min)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private min = inject(new HostAttributeToken('minLength')); | |
| validator: Function; | |
| constructor(@Attribute('minLength') private min: number) { | |
| this.validator = minLengthArrayValidator(min); | |
| constructor() { | |
| const min = this.min; | |
| this.validator = minLengthArrayValidator(Number(min)); | |
| validator: Function; | |
| constructor() { | |
| const min = inject(new HostAttributeToken('minLength')); | |
| this.validator = minLengthArrayValidator(Number(min)); |
Guide und schematic: https://angular.dev/reference/migrations/inject-function
Den müssen wir nicht unbedingt mergen finde ich. Konstruktor Injection funktioniert ja. Die Argumente für und gegen sind auch ein bisschen esoterisch finde ich...
Aber Angular pushed halt schon in die Richtung
inject()und deshalb hätte ich es jetzt einfach gemacht.