(core) Use inject for dependencies

This commit is contained in:
Sercan Yemen 2023-11-20 10:06:06 +03:00
parent eb43394ed1
commit e884ccafe8
4 changed files with 8 additions and 35 deletions

View File

@ -1,5 +1,5 @@
import { HttpClient } from '@angular/common/http'; 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 { AuthUtils } from 'app/core/auth/auth.utils';
import { UserService } from 'app/core/user/user.service'; import { UserService } from 'app/core/user/user.service';
import { catchError, Observable, of, switchMap, throwError } from 'rxjs'; import { catchError, Observable, of, switchMap, throwError } from 'rxjs';
@ -8,16 +8,8 @@ import { catchError, Observable, of, switchMap, throwError } from 'rxjs';
export class AuthService export class AuthService
{ {
private _authenticated: boolean = false; private _authenticated: boolean = false;
private _httpClient = inject(HttpClient);
/** private _userService = inject(UserService);
* Constructor
*/
constructor(
private _httpClient: HttpClient,
private _userService: UserService,
)
{
}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Accessors // @ Accessors

View File

@ -7,13 +7,6 @@
export class AuthUtils export class AuthUtils
{ {
/**
* Constructor
*/
constructor()
{
}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Public methods // @ Public methods
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------

View File

@ -1,20 +1,14 @@
import { HttpClient } from '@angular/common/http'; 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 { Navigation } from 'app/core/navigation/navigation.types';
import { Observable, ReplaySubject, tap } from 'rxjs'; import { Observable, ReplaySubject, tap } from 'rxjs';
@Injectable({providedIn: 'root'}) @Injectable({providedIn: 'root'})
export class NavigationService export class NavigationService
{ {
private _httpClient = inject(HttpClient);
private _navigation: ReplaySubject<Navigation> = new ReplaySubject<Navigation>(1); private _navigation: ReplaySubject<Navigation> = new ReplaySubject<Navigation>(1);
/**
* Constructor
*/
constructor(private _httpClient: HttpClient)
{
}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Accessors // @ Accessors
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------

View File

@ -1,20 +1,14 @@
import { HttpClient } from '@angular/common/http'; 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 { User } from 'app/core/user/user.types';
import { map, Observable, ReplaySubject, tap } from 'rxjs'; import { map, Observable, ReplaySubject, tap } from 'rxjs';
@Injectable({providedIn: 'root'}) @Injectable({providedIn: 'root'})
export class UserService export class UserService
{ {
private _httpClient = inject(HttpClient);
private _user: ReplaySubject<User> = new ReplaySubject<User>(1); private _user: ReplaySubject<User> = new ReplaySubject<User>(1);
/**
* Constructor
*/
constructor(private _httpClient: HttpClient)
{
}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Accessors // @ Accessors
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -40,7 +34,7 @@ export class UserService
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
/** /**
* Get the current logged in user data * Get the current signed-in user data
*/ */
get(): Observable<User> get(): Observable<User>
{ {