Skip to content

Commit e45229b

Browse files
committed
chore: inject() function migration
1 parent 729959c commit e45229b

File tree

156 files changed

+789
-1038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+789
-1038
lines changed

.global/integration-app.style.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ $ng-app-variable-theme: mat.m2-define-light-theme(
1313
accent: $ng-app-variable-accent,
1414
warn: $ng-app-variable-warn,
1515
),
16+
typography: mat.m2-define-typography-config(),
1617
density: -1,
1718
)
1819
);
1920

2021
@include mat.all-component-themes($ng-app-variable-theme);
22+
@include mat.typography-hierarchy($ng-app-variable-theme);
2123
@include mat.form-field-density(-4);
2224

2325
html,

apps/cdk-demo/src/samples/guide/guide.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ChangeDetectionStrategy, Component} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
22
import {FormBuilder, FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms';
33
import {MatFormField, MatInput, MatLabel} from '@angular/material/input';
44
import {AmountFormat, InputFilter} from '@angular-ru/cdk/directives';
@@ -20,12 +20,12 @@ import {REG_EXP_ONLY_NUMBERS} from './properties/constants';
2020
changeDetection: ChangeDetectionStrategy.OnPush,
2121
})
2222
export default class GuideComponent {
23+
private readonly fb = inject(FormBuilder);
24+
2325
public value = 'abc';
2426
public valueNumbers = '123';
2527
public filterRegExp = /[a-z]+/;
2628
public onlyNumbers: RegExp = REG_EXP_ONLY_NUMBERS;
2729
public amountForm: FormGroup = this.fb.group({sum: null});
2830
public filterControl: FormControl = new FormControl(this.value);
29-
30-
constructor(private readonly fb: FormBuilder) {}
3131
}

apps/excel-demo/src/app.component.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
inject,
5+
ViewEncapsulation,
6+
} from '@angular/core';
27
import {MatButton} from '@angular/material/button';
38
import {MatDivider, MatList, MatListItem} from '@angular/material/list';
49
import {MatDrawer, MatDrawerContainer, MatDrawerContent} from '@angular/material/sidenav';
@@ -34,6 +39,9 @@ interface A {
3439
changeDetection: ChangeDetectionStrategy.OnPush,
3540
})
3641
export class AppComponent {
42+
protected excel = inject(ExcelService);
43+
private readonly translate = inject(TranslateService);
44+
3745
public data: A[] = [
3846
{
3947
id: 'id',
@@ -45,10 +53,7 @@ export class AppComponent {
4553
},
4654
];
4755

48-
constructor(
49-
protected excel: ExcelService,
50-
private readonly translate: TranslateService,
51-
) {
56+
constructor() {
5257
this.translate.setDefaultLang('ru');
5358
}
5459

apps/http-demo/src/samples/guide/guide.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import {ChangeDetectionStrategy, Component, OnDestroy, OnInit} from '@angular/core';
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
inject,
5+
OnDestroy,
6+
OnInit,
7+
} from '@angular/core';
28
import {Subject} from 'rxjs';
39
import {takeUntil} from 'rxjs/operators';
410

@@ -10,9 +16,9 @@ import {ApiClient} from '../../services/clients/api.client';
1016
changeDetection: ChangeDetectionStrategy.OnPush,
1117
})
1218
export default class GuideComponent implements OnInit, OnDestroy {
13-
private readonly destroy$ = new Subject<void>();
19+
private readonly apiClient = inject(ApiClient);
1420

15-
constructor(private readonly apiClient: ApiClient) {}
21+
private readonly destroy$ = new Subject<void>();
1622

1723
public ngOnInit(): void {
1824
this.fetchData();

apps/logger-demo/src/app.component.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {
1313
TraceLog,
1414
WarnLog,
1515
} from '@angular-ru/cdk/logger';
16-
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core';
16+
import {
17+
ChangeDetectionStrategy,
18+
Component,
19+
ViewEncapsulation,
20+
inject,
21+
} from '@angular/core';
1722

1823
@Component({
1924
selector: 'app-root',
@@ -23,6 +28,8 @@ import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/co
2328
encapsulation: ViewEncapsulation.None,
2429
})
2530
export class AppComponent {
31+
private readonly logger = inject(LoggerService);
32+
2633
@Logger() public loggerInjection!: LoggerService;
2734
@TraceLog() public trace!: LogFn;
2835
@DebugLog() public debug!: LogFn;
@@ -37,8 +44,6 @@ export class AppComponent {
3744
private readonly warnIsWork: string = 'warn is worked';
3845
private readonly errorIsWork: string = 'error is worked';
3946

40-
constructor(private readonly logger: LoggerService) {}
41-
4247
public exampleBasicMethods(): void {
4348
this.logger.clear();
4449
this.log('log is worked');
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ChangeDetectionStrategy, Component} from '@angular/core';
1+
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
22
import {FormsModule} from '@angular/forms';
33

44
import {AmountState} from './amount.state';
@@ -11,8 +11,6 @@ import {PriceState} from './price.state';
1111
changeDetection: ChangeDetectionStrategy.OnPush,
1212
})
1313
export class AmountComponent {
14-
constructor(
15-
public price: PriceState,
16-
public amount: AmountState,
17-
) {}
14+
public price = inject(PriceState);
15+
public amount = inject(AmountState);
1816
}

apps/ngxs-demo/src/amount/amount.state.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable} from '@angular/core';
1+
import {inject, Injectable} from '@angular/core';
22
import {Computed, StateRepository} from '@angular-ru/ngxs/decorators';
33
import {NgxsDataRepository} from '@angular-ru/ngxs/repositories';
44
import {State} from '@ngxs/store';
@@ -12,9 +12,7 @@ import {PriceState} from './price.state';
1212
})
1313
@Injectable()
1414
export class AmountState extends NgxsDataRepository<number> {
15-
constructor(private readonly price: PriceState) {
16-
super();
17-
}
15+
private readonly price = inject(PriceState);
1816

1917
@Computed()
2018
public get sum(): number {

apps/ngxs-demo/src/app.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import {AsyncPipe, JsonPipe} from '@angular/common';
2-
import {ChangeDetectionStrategy, Component, isDevMode, OnInit} from '@angular/core';
2+
import {
3+
ChangeDetectionStrategy,
4+
Component,
5+
inject,
6+
isDevMode,
7+
OnInit,
8+
} from '@angular/core';
39
import {RouterLink, RouterOutlet} from '@angular/router';
410
import {Store} from '@ngxs/store';
511
import {Observable} from 'rxjs';
@@ -11,12 +17,12 @@ import {Observable} from 'rxjs';
1117
changeDetection: ChangeDetectionStrategy.OnPush,
1218
})
1319
export class AppComponent implements OnInit {
20+
private readonly store = inject(Store);
21+
1422
public snapshot$: Observable<unknown> = this.store.select(
1523
(state: unknown): unknown => state,
1624
);
1725

18-
constructor(private readonly store: Store) {}
19-
2026
public ngOnInit(): void {
2127
// eslint-disable-next-line no-console
2228
console.log('[isDevMode]', isDevMode());

apps/ngxs-demo/src/app.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import {provideNgxsDataPlugin} from '@angular-ru/ngxs';
1616
import {withNgxsDataStorage} from '@angular-ru/ngxs/storage';
1717
import {withNgxsLoggerPlugin} from '@ngxs/logger-plugin';
18-
import {provideStore} from '@ngxs/store';
18+
import {provideStore, withNgxsNoopExecutionStrategy} from '@ngxs/store';
1919

2020
import {environment} from '../environments/environment';
2121
import {routes} from './app.routes';
@@ -43,6 +43,7 @@ export const appConfig: ApplicationConfig = {
4343
developmentMode: !environment.production,
4444
},
4545
withNgxsLoggerPlugin(),
46+
withNgxsNoopExecutionStrategy(),
4647
),
4748
provideNgxsDataPlugin(withNgxsDataStorage()),
4849
],

apps/ngxs-demo/src/article/article.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {AsyncPipe} from '@angular/common';
2-
import {ChangeDetectionStrategy, Component, OnDestroy} from '@angular/core';
2+
import {ChangeDetectionStrategy, Component, inject, OnDestroy} from '@angular/core';
33
import {MatButton, MatIconButton} from '@angular/material/button';
44
import {MatDialog} from '@angular/material/dialog';
55
import {MatIcon} from '@angular/material/icon';
@@ -48,12 +48,10 @@ import {ArticleDialogComponent} from './dialog/article-dialog.component';
4848
changeDetection: ChangeDetectionStrategy.OnPush,
4949
})
5050
export class ArticleComponent implements OnDestroy {
51-
private readonly destroy$ = new Subject<void>();
51+
public dialog = inject(MatDialog);
52+
public articleEntities = inject(ArticleEntitiesState);
5253

53-
constructor(
54-
public dialog: MatDialog,
55-
public articleEntities: ArticleEntitiesState,
56-
) {}
54+
private readonly destroy$ = new Subject<void>();
5755

5856
public ngOnDestroy(): void {
5957
this.destroy$.next();

0 commit comments

Comments
 (0)