1 import { Injectable } from '@angular/core';
2 import { Observable, of, EMPTY } from 'rxjs';
3 import { Hero } from './hero';
4 import { HEROES } from './mock-heroes';
5 import { MessageService } from './message.service';
11 export class HeroService {
13 constructor(private messageService : MessageService) { }
15 getHeroes() : Observable<Hero[]> {
16 this.messageService.add('HeroService: fetching heroes...');
20 getHero(id: number): Observable<Hero> {
21 this.messageService.add(`HeroService: requested hero id=${id}`);
22 const found: Hero | undefined = HEROES.find(hero => hero.id === id);
23 if (found === undefined) {