2015-12-16 21:47:02 -05:00
|
|
|
// #docplaster
|
|
|
|
// #docregion
|
2015-12-01 06:15:14 -05:00
|
|
|
// #docregion just-get-heroes
|
2016-05-03 08:06:32 -04:00
|
|
|
import { Injectable } from '@angular/core';
|
2016-03-15 08:24:50 -04:00
|
|
|
|
2016-05-03 08:06:32 -04:00
|
|
|
import { Hero } from './hero';
|
|
|
|
import { HEROES } from './mock-heroes';
|
2015-12-16 21:47:02 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HeroService {
|
2016-05-13 16:32:54 -04:00
|
|
|
// #docregion get-heroes
|
2015-12-16 21:47:02 -05:00
|
|
|
getHeroes() {
|
|
|
|
return Promise.resolve(HEROES);
|
|
|
|
}
|
2016-05-13 16:32:54 -04:00
|
|
|
// #enddocregion get-heroes
|
2015-12-01 06:15:14 -05:00
|
|
|
// #enddocregion just-get-heroes
|
2015-12-16 21:47:02 -05:00
|
|
|
// See the "Take it slow" appendix
|
2016-05-13 16:32:54 -04:00
|
|
|
// #docregion get-heroes-slowly
|
2015-12-16 21:47:02 -05:00
|
|
|
getHeroesSlowly() {
|
2015-12-22 13:25:30 -05:00
|
|
|
return new Promise<Hero[]>(resolve =>
|
2015-12-16 21:47:02 -05:00
|
|
|
setTimeout(()=>resolve(HEROES), 2000) // 2 seconds
|
|
|
|
);
|
|
|
|
}
|
2016-05-13 16:32:54 -04:00
|
|
|
// #enddocregion get-heroes-slowly
|
2015-12-01 06:15:14 -05:00
|
|
|
// #docregion just-get-heroes
|
2015-12-16 21:47:02 -05:00
|
|
|
}
|
2015-12-01 06:15:14 -05:00
|
|
|
// #enddocregion just-get-heroes
|
2016-05-03 08:06:32 -04:00
|
|
|
// #enddocregion
|