diff --git a/src/app/rxjs-app/app/components/fruits-list.component.ts b/src/app/rxjs-app/app/components/fruits-list.component.ts
index 0b0ff12..a51967d 100644
--- a/src/app/rxjs-app/app/components/fruits-list.component.ts
+++ b/src/app/rxjs-app/app/components/fruits-list.component.ts
@@ -1,21 +1,29 @@
-import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
-import { FruitService } from '../../shared/services/fruits.service';
-import { CartService } from '../../shared/services/cart.service';
+import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
+import {FruitService} from '../../shared/services/fruits.service';
+import {CartService} from '../../shared/services/cart.service';
+import {Fruit} from "../../shared/model/fruit";
+import {Observable} from "rxjs";
@Component({
selector: 'app-fruits-list',
template: `
-
- {{fruit.name}} - {{fruit.price}}€
+
+ {{ fruit.name }} - {{ fruit.price }}€
`,
styles: ``,
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class FruitsListComponent {
+export class FruitsListComponent implements OnInit {
fruitsService = inject(FruitService)
cartService = inject(CartService)
+ fruitsList$?: Observable;
+
+ ngOnInit() {
+ this.fruitsList$ = this.fruitsService.fruitList
+
+ }
}
diff --git a/src/app/rxjs-app/shared/services/cart.service.ts b/src/app/rxjs-app/shared/services/cart.service.ts
index bec75fa..f340176 100644
--- a/src/app/rxjs-app/shared/services/cart.service.ts
+++ b/src/app/rxjs-app/shared/services/cart.service.ts
@@ -1,18 +1,18 @@
-import { Injectable } from '@angular/core';
-import { Fruit, FruitState } from '../model/fruit';
-import { BehaviorSubject, Observable, map } from 'rxjs';
+import {Injectable} from '@angular/core';
+import {Fruit, FruitState} from '../model/fruit';
+import {BehaviorSubject, Observable} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class CartService {
- /* Le type du panier peut faire peur, nous allons le décomposer
+ /* Le type du panier peut faire peur, nous allons le décomposer
- L'état du panier est stocké sous la forme d'une Map
- K est la clé de notre map, ici un nombre, qui va correspondre à l'id d'un fruit
- V est un objet de type FruitState, qui est le type Fruit avec une quantité associée
- - Par exemple, pour représenter 10 oranges dans notre panier :
+ - Par exemple, pour représenter 10 oranges dans notre panier :
cart.set(2, { id: 2, name: "Orange", price: 3, quantity: 10 })
- La clé est 2, id de notre fruit
- { id: 2,
@@ -25,7 +25,7 @@ export class CartService {
cart$: Observable