Patrice Chalin 2bd9946bda example(toh-4,5): getHeroesSlowly() to return getHeroes() (#2152)
* example(dart/toh-4,5): getHeroesSlowly() to return getHeroes()

Have `getHeroesSlowly()` delay and then return the value of
`getHeroes()`. This makes it easier for user’s performing the tutorial
to keep this slower method as they evolve toh-5 into toh-6.

* example(ts/toh-4,5): getHeroesSlowly() to return getHeroes()

Have `getHeroesSlowly()` delay and then return the value of
`getHeroes()`. This makes it easier for user’s performing the tutorial
to keep this slower method as they evolve toh-5 into toh-6.
2016-08-26 14:39:57 -07:00

27 lines
622 B
Dart

// #docplaster
// #docregion
// #docregion just-get-heroes
import 'dart:async';
import 'package:angular2/core.dart';
import 'hero.dart';
import 'mock_heroes.dart';
@Injectable()
class HeroService {
// #docregion get-heroes
Future<List<Hero>> getHeroes() async => mockHeroes;
// #enddocregion get-heroes, just-get-heroes
// #enddocregion
// See the "Take it slow" appendix
// #docregion get-heroes-slowly
Future<List<Hero>> getHeroesSlowly() {
return new Future.delayed(const Duration(seconds: 2), getHeroes);
}
// #enddocregion get-heroes-slowly
// #docregion
// #docregion just-get-heroes
}