Renommage de code

This commit is contained in:
Florian THIERRY
2023-02-22 10:14:31 +01:00
parent 0fffd47436
commit 4ca604503c
7 changed files with 8 additions and 79 deletions

View File

@@ -2,15 +2,15 @@
<h1>Les appels réseaux - Promesses ou Observables ?</h1> <h1>Les appels réseaux - Promesses ou Observables ?</h1>
<div class="actions"> <div class="actions">
<button mat-raised-button <button mat-raised-button
(click)="loadCar()" (click)="loadCarViaAPromise()"
[disabled]="isLoading$ | async"> [disabled]="isLoading$ | async">
Load the car 🙏 Load the car via a Promise
</button> </button>
<button mat-raised-button <button mat-raised-button
(click)="loadCarViaAnObservable()" (click)="loadCarViaAnObservable()"
[disabled]="isLoading$ | async"> [disabled]="isLoading$ | async">
Load the car 👁️ Load the car via an Observable
</button> </button>
</div> </div>
<div class="loading" *ngIf="isLoading$ | async"> <div class="loading" *ngIf="isLoading$ | async">

View File

@@ -26,7 +26,7 @@ export class NetworkCallComponent {
return this.isLoadingSubject.asObservable(); return this.isLoadingSubject.asObservable();
} }
loadCar(): void { loadCarViaAPromise(): void {
this.loadThroughAPromise(); this.loadThroughAPromise();
} }

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ObservablesExampleComponent } from './observables-example.component';
describe('ObservablesExampleComponent', () => {
let component: ObservablesExampleComponent;
let fixture: ComponentFixture<ObservablesExampleComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ObservablesExampleComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(ObservablesExampleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -2,13 +2,11 @@
<h1>Les promesses</h1> <h1>Les promesses</h1>
<div class="actions"> <div class="actions">
<button mat-raised-button (click)="showCarViaAPromise()" [disabled]="isLoading"> <button mat-raised-button (click)="showCarViaAPromise()" [disabled]="isLoading">
<mat-icon>visibility</mat-icon> 🙏 Show car via a Promise
Show car via a Promise
</button> </button>
<button mat-raised-button (click)="showCarViaAsyncAwaitProcess()" [disabled]="isLoading"> <button mat-raised-button (click)="showCarViaAsyncAwaitProcess()" [disabled]="isLoading">
<mat-icon>visibility</mat-icon> ⏱️ Show car via an Async Await process
Show car via an Async Await process
</button> </button>
</div> </div>

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PromisesExampleComponent } from './promises-example.component';
describe('PromisesExampleComponent', () => {
let component: PromisesExampleComponent;
let fixture: ComponentFixture<PromisesExampleComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ PromisesExampleComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(PromisesExampleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -43,7 +43,7 @@ export class PromisesExampleComponent {
this.isLoaded = true; this.isLoaded = true;
}) })
.catch(error => { .catch(error => {
this.snackBar.open(`Error while loading car. Cause : ${error}`); this.snackBar.open(`Error while loading car. Cause : ${error}`, 'Close', { duration: 5000 });
}) })
.finally(() => { .finally(() => {
this.isLoading = false; this.isLoading = false;
@@ -78,7 +78,7 @@ export class PromisesExampleComponent {
this.car = await this.findViaAsyncAwaitProcess(); this.car = await this.findViaAsyncAwaitProcess();
this.isLoaded = true; this.isLoaded = true;
} catch (error) { } catch (error) {
this.snackBar.open(`Error while loading car. Cause : ${error}`); this.snackBar.open(`Error while loading car. Cause : ${error}`, 'Close', { duration: 5000 });
} }
this.numberOfLoadings++; this.numberOfLoadings++;

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StateManagementExampleComponent } from './state-management-example.component';
describe('StateManagementExampleComponent', () => {
let component: StateManagementExampleComponent;
let fixture: ComponentFixture<StateManagementExampleComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ StateManagementExampleComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(StateManagementExampleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});