docs: align `toh-pt5` code with `toh-pt4` (#41234)

This commit aligns the code of `HeroService` `getHeroes()` and
`getHero()` methods in `toh-pt5` with that of `toh-pt4`. I.e. it applies
the changes from #40419 to `toh-pt5`.

PR Close #41234
This commit is contained in:
George Kalpakas 2021-03-16 23:18:31 +02:00 committed by Misko Hevery
parent 81d2aabcbb
commit 6d47b05b5b
1 changed files with 4 additions and 4 deletions

View File

@ -12,16 +12,16 @@ export class HeroService {
constructor(private messageService: MessageService) { } constructor(private messageService: MessageService) { }
getHeroes(): Observable<Hero[]> { getHeroes(): Observable<Hero[]> {
// TODO: send the message _after_ fetching the heroes const heroes = of(HEROES);
this.messageService.add('HeroService: fetched heroes'); this.messageService.add('HeroService: fetched heroes');
return of(HEROES); return heroes;
} }
// #docregion getHero // #docregion getHero
getHero(id: number): Observable<Hero> { getHero(id: number): Observable<Hero> {
// TODO: send the message _after_ fetching the hero const hero = HEROES.find(h => h.id === id);
this.messageService.add(`HeroService: fetched hero id=${id}`); this.messageService.add(`HeroService: fetched hero id=${id}`);
return of(HEROES.find(hero => hero.id === id)); return of(hero);
} }
// #enddocregion getHero // #enddocregion getHero
} }