From ebe46a0d115c6782b7160b643b174981621d2aa6 Mon Sep 17 00:00:00 2001 From: Florian THIERRY Date: Mon, 2 Feb 2026 17:38:57 +0100 Subject: [PATCH] Convert observables to signals. --- .../src/app/components/footer/footer.component.html | 6 +++--- .../src/app/components/footer/footer.component.scss | 3 ++- .../src/app/components/footer/footer.component.ts | 4 +--- .../publication-list/publication-list.component.html | 4 ++-- .../publication-list/publication-list.component.ts | 7 +++---- frontend/src/app/pages/home/home.component.html | 6 +++--- frontend/src/app/pages/home/home.component.ts | 11 ++++++----- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/frontend/src/app/components/footer/footer.component.html b/frontend/src/app/components/footer/footer.component.html index 99b3a78..f025fd8 100644 --- a/frontend/src/app/components/footer/footer.component.html +++ b/frontend/src/app/components/footer/footer.component.html @@ -1,8 +1,8 @@
© - 2016 - 2024 All rights reserved + 2016 - 2026 All rights reserved - - 2.1 + 2.2 favorite @@ -11,4 +11,4 @@ menu_book - Development realised by Florian THIERRY -
\ No newline at end of file + diff --git a/frontend/src/app/components/footer/footer.component.scss b/frontend/src/app/components/footer/footer.component.scss index fa70f40..1784222 100644 --- a/frontend/src/app/components/footer/footer.component.scss +++ b/frontend/src/app/components/footer/footer.component.scss @@ -12,6 +12,7 @@ display: flex; flex-direction: row; align-items: center; + gap: .2em; .copy-left { transform: rotate(180deg); @@ -28,4 +29,4 @@ align-items: center; } } -} \ No newline at end of file +} diff --git a/frontend/src/app/components/footer/footer.component.ts b/frontend/src/app/components/footer/footer.component.ts index d40b77f..0e62bc6 100644 --- a/frontend/src/app/components/footer/footer.component.ts +++ b/frontend/src/app/components/footer/footer.component.ts @@ -9,6 +9,4 @@ import { RouterModule } from '@angular/router'; templateUrl: './footer.component.html', styleUrl: './footer.component.scss' }) -export class FooterComponent { - -} +export class FooterComponent {} diff --git a/frontend/src/app/components/publication-list/publication-list.component.html b/frontend/src/app/components/publication-list/publication-list.component.html index f1d3598..7986926 100644 --- a/frontend/src/app/components/publication-list/publication-list.component.html +++ b/frontend/src/app/components/publication-list/publication-list.component.html @@ -1,4 +1,4 @@ -@for(publication of publications$ | async; track publication) { +@for(publication of publications(); track publication.id) {
@@ -13,4 +13,4 @@
-} \ No newline at end of file +} diff --git a/frontend/src/app/components/publication-list/publication-list.component.ts b/frontend/src/app/components/publication-list/publication-list.component.ts index f9d55b6..43b2d91 100644 --- a/frontend/src/app/components/publication-list/publication-list.component.ts +++ b/frontend/src/app/components/publication-list/publication-list.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from "@angular/core"; +import {Component, input, Input} from "@angular/core"; import { Publication } from "../../core/rest-services/publications/model/publication"; import { Observable } from "rxjs"; import { CommonModule } from "@angular/common"; @@ -12,6 +12,5 @@ import { MatTooltipModule } from "@angular/material/tooltip"; imports: [CommonModule, RouterModule, MatTooltipModule] }) export class PublicationListComponent { - @Input() - publications$!: Observable; -} \ No newline at end of file + publications = input.required(); +} diff --git a/frontend/src/app/pages/home/home.component.html b/frontend/src/app/pages/home/home.component.html index d5922ca..b49b967 100644 --- a/frontend/src/app/pages/home/home.component.html +++ b/frontend/src/app/pages/home/home.component.html @@ -1,10 +1,10 @@

Last publications

-@if ((isLoading$ | async) === true) { +@if ((isLoading())) {

Publications loading...

} @else { - @if ((publications$ | async) != []) { - + @if (publications(); as publications) { + } @else {

No any publication.

} diff --git a/frontend/src/app/pages/home/home.component.ts b/frontend/src/app/pages/home/home.component.ts index 600729a..1c2756c 100644 --- a/frontend/src/app/pages/home/home.component.ts +++ b/frontend/src/app/pages/home/home.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit, inject } from '@angular/core'; +import {Component, OnInit, inject, Signal} from '@angular/core'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { Observable } from 'rxjs'; import { PublicationListComponent } from '../../components/publication-list/publication-list.component'; import { Publication } from '../../core/rest-services/publications/model/publication'; import { HomeService } from './home.service'; import { CommonModule } from '@angular/common'; +import {toSignal} from "@angular/core/rxjs-interop"; @Component({ selector: 'app-home', @@ -20,12 +21,12 @@ import { CommonModule } from '@angular/common'; export class HomeComponent implements OnInit { private homeService = inject(HomeService); - get isLoading$(): Observable { - return this.homeService.isLoading$; + get isLoading(): Signal { + return toSignal(this.homeService.isLoading$, { initialValue: false }); } - get publications$(): Observable { - return this.homeService.publications$; + get publications(): Signal { + return toSignal(this.homeService.publications$, { initialValue: [] }); } ngOnInit(): void {