Skip to content

Commit dc15ba8

Browse files
committed
refactor: exchange injectable by service decorator
1 parent 2393658 commit dc15ba8

19 files changed

Lines changed: 38 additions & 51 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Injectable, signal } from '@angular/core';
1+
import { Service, signal } from '@angular/core';
22

3-
@Injectable({ providedIn: 'root' })
3+
@Service()
44
export class UserService {
55
readonly userName = signal('Jane Doe');
66
}

src/app/domains/luggage/data/luggage-client.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { Injectable, resource } from '@angular/core';
1+
import { resource, Service } from '@angular/core';
22
import { Observable, of } from 'rxjs';
33

44
import { Luggage } from './luggage';
55

6-
@Injectable({
7-
providedIn: 'root',
8-
})
6+
@Service()
97
export class LuggageClient {
108
find(): Observable<Luggage[]> {
119
return of(this.getLuggage());

src/app/domains/luggage/feature-luggage/luggage-overview/simple-luggage-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { inject, Injectable, signal } from '@angular/core';
1+
import { inject, Service, signal } from '@angular/core';
22

33
import { LuggageClient } from '../../data/luggage-client';
44

5-
@Injectable()
5+
@Service({ autoProvided: false })
66
export class SimpleLuggageStore {
77
private luggageClient = inject(LuggageClient);
88

src/app/domains/shared/ui-assistant/chat-registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core';
1+
import { Service } from '@angular/core';
22
import { UiChatResourceRef } from '@hashbrownai/angular';
33
import { Chat } from '@hashbrownai/core';
44
import { Subject } from 'rxjs';
@@ -7,7 +7,7 @@ export interface ChatInfo {
77
chat: UiChatResourceRef<Chat.AnyTool> | null;
88
}
99

10-
@Injectable({ providedIn: 'root' })
10+
@Service()
1111
export class ChatRegistry {
1212
private chat: UiChatResourceRef<Chat.AnyTool> | null = null;
1313
private _chatInfo = new Subject<ChatInfo>();

src/app/domains/shared/ui-common/dialog/dialog-outlet-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import {
66
DOCUMENT,
77
EnvironmentInjector,
88
inject,
9-
Injectable,
9+
Service,
1010
} from '@angular/core';
1111

1212
import { DialogOutlet } from './dialog-outlet';
1313

14-
@Injectable({ providedIn: 'root' })
14+
@Service()
1515
export class DialogOutletService {
1616
private envInjector = inject(EnvironmentInjector);
1717
private appRef = inject(ApplicationRef);

src/app/domains/shared/ui-common/dialog/dialog.service.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { inject, Injectable, Type } from '@angular/core';
1+
import { inject, Service, Type } from '@angular/core';
22
import { Subject } from 'rxjs';
33

44
import { DialogEvent } from './dialog-event';
55
import { DialogOutletService } from './dialog-outlet-service';
66

7-
@Injectable({
8-
providedIn: 'root',
9-
})
7+
@Service()
108
export class DialogService {
119
private dialogOutletService = inject(DialogOutletService);
1210

src/app/domains/shared/ui-common/service-tabbed-pane/tab-registry.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { computed, Injectable, Signal, signal } from '@angular/core';
1+
import { computed, Service, Signal, signal } from '@angular/core';
22

33
export interface TabInfo {
44
title: Signal<string>;
55
}
66

7-
// No { providedIn: 'root' }!
87
// This service is provided in the tabbed-pane
9-
@Injectable()
8+
@Service({ autoProvided: false })
109
export class TabRegistry {
1110
private readonly _current = signal(0);
1211
private readonly _tabs = signal<TabInfo[]>([]);

src/app/domains/shared/util-auth/auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Injectable, signal } from '@angular/core';
1+
import { Service, signal } from '@angular/core';
22

3-
@Injectable({ providedIn: 'root' })
3+
@Service()
44
export class AuthService {
55
private readonly _isLoggedIn = signal(true);
66
readonly isLoggedIn = this._isLoggedIn.asReadonly();

src/app/domains/shared/util-common/application-error-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import {
22
EnvironmentProviders,
33
ErrorHandler,
44
inject,
5-
Injectable,
65
makeEnvironmentProviders,
6+
Service,
77
} from '@angular/core';
88
import { MatSnackBar } from '@angular/material/snack-bar';
99

10-
@Injectable()
10+
@Service({ autoProvided: false })
1111
export class ApplicationlErrorHandler implements ErrorHandler {
1212
private snackBar = inject(MatSnackBar);
1313

src/app/domains/shared/util-common/config-service.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { HttpClient } from '@angular/common/http';
2-
import { inject, Injectable } from '@angular/core';
2+
import { inject, Service } from '@angular/core';
33
import { firstValueFrom } from 'rxjs';
44

55
export interface Config {
66
readonly baseUrl: string;
77
readonly model: string;
88
}
99

10-
@Injectable({
11-
providedIn: 'root',
12-
})
10+
@Service()
1311
export class ConfigService {
1412
private readonly http = inject(HttpClient);
1513

0 commit comments

Comments
 (0)