From e884ccafe8bf0e54d72ad0d55038bdcf495eb24a Mon Sep 17 00:00:00 2001 From: Sercan Yemen <117369+srcn@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:06:06 +0300 Subject: [PATCH] (core) Use inject for dependencies --- src/app/core/auth/auth.service.ts | 14 +++----------- src/app/core/auth/auth.utils.ts | 7 ------- src/app/core/navigation/navigation.service.ts | 10 ++-------- src/app/core/user/user.service.ts | 12 +++--------- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index dcd7bf72..794acab5 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { AuthUtils } from 'app/core/auth/auth.utils'; import { UserService } from 'app/core/user/user.service'; import { catchError, Observable, of, switchMap, throwError } from 'rxjs'; @@ -8,16 +8,8 @@ import { catchError, Observable, of, switchMap, throwError } from 'rxjs'; export class AuthService { private _authenticated: boolean = false; - - /** - * Constructor - */ - constructor( - private _httpClient: HttpClient, - private _userService: UserService, - ) - { - } + private _httpClient = inject(HttpClient); + private _userService = inject(UserService); // ----------------------------------------------------------------------------------------------------- // @ Accessors diff --git a/src/app/core/auth/auth.utils.ts b/src/app/core/auth/auth.utils.ts index 233fe799..38d02396 100644 --- a/src/app/core/auth/auth.utils.ts +++ b/src/app/core/auth/auth.utils.ts @@ -7,13 +7,6 @@ export class AuthUtils { - /** - * Constructor - */ - constructor() - { - } - // ----------------------------------------------------------------------------------------------------- // @ Public methods // ----------------------------------------------------------------------------------------------------- diff --git a/src/app/core/navigation/navigation.service.ts b/src/app/core/navigation/navigation.service.ts index 7309b151..e5dbeb50 100644 --- a/src/app/core/navigation/navigation.service.ts +++ b/src/app/core/navigation/navigation.service.ts @@ -1,20 +1,14 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Navigation } from 'app/core/navigation/navigation.types'; import { Observable, ReplaySubject, tap } from 'rxjs'; @Injectable({providedIn: 'root'}) export class NavigationService { + private _httpClient = inject(HttpClient); private _navigation: ReplaySubject = new ReplaySubject(1); - /** - * Constructor - */ - constructor(private _httpClient: HttpClient) - { - } - // ----------------------------------------------------------------------------------------------------- // @ Accessors // ----------------------------------------------------------------------------------------------------- diff --git a/src/app/core/user/user.service.ts b/src/app/core/user/user.service.ts index a7d71d02..ee4ba2b4 100644 --- a/src/app/core/user/user.service.ts +++ b/src/app/core/user/user.service.ts @@ -1,20 +1,14 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { User } from 'app/core/user/user.types'; import { map, Observable, ReplaySubject, tap } from 'rxjs'; @Injectable({providedIn: 'root'}) export class UserService { + private _httpClient = inject(HttpClient); private _user: ReplaySubject = new ReplaySubject(1); - /** - * Constructor - */ - constructor(private _httpClient: HttpClient) - { - } - // ----------------------------------------------------------------------------------------------------- // @ Accessors // ----------------------------------------------------------------------------------------------------- @@ -40,7 +34,7 @@ export class UserService // ----------------------------------------------------------------------------------------------------- /** - * Get the current logged in user data + * Get the current signed-in user data */ get(): Observable {