| 
									
										
										
										
											2016-03-26 12:18:13 -04:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-04-27 11:28:22 -07:00
										 |  |  | import {Injectable}  from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-03-26 12:18:13 -04:00
										 |  |  | import {Hero}        from './hero'; | 
					
						
							|  |  |  | import {HeroService} from './hero.service'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // #docregion service
 | 
					
						
							|  |  |  | @Injectable() | 
					
						
							|  |  |  | export class HeroCacheService { | 
					
						
							|  |  |  |   hero:Hero; | 
					
						
							|  |  |  |   constructor(private _heroService:HeroService){} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fetchCachedHero(id:number){ | 
					
						
							|  |  |  |     if (!this.hero) { | 
					
						
							|  |  |  |       this.hero = this._heroService.getHeroById(id); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return this.hero | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion service
 |