I have some questions about Angular Service Tutorial Code:
- What does the TODO comment mean in the below code?
- If we add a message here, is it possible that the message is added before the HEROES are fetched because Observable is asynchronous and we do not have control over it?
- Would it be better to add the message in the subscribe function of the caller who receives the Observable?
getHeroes(): Observable<Hero[]> {
// TODO: send the message _after_ fetching the heroes
this.messageService.add('HeroService: fetched heroes');
return of(HEROES);
}
I expect the "HEROES are fetched" message is only added after the HEROES are actually fetched.