Skip to content

Instantly share code, notes, and snippets.

@nerdic-coder
Created April 27, 2018 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdic-coder/d409813fd695bd21b2c6a84f7b4195a7 to your computer and use it in GitHub Desktop.
Save nerdic-coder/d409813fd695bd21b2c6a84f7b4195a7 to your computer and use it in GitHub Desktop.
hero.service.ts
import { Observable } from 'rxjs';
import { of } from 'rxjs';
import { Hero } from '../models/hero';
import { HEROES } from './mock-heroes';
export class HeroService {
private static _instance: HeroService;
getHeroes(): Observable<Hero[]> {
return of(HEROES);
}
public static get Instance(): HeroService {
// Do you need arguments? Make it a regular method instead.
return this._instance || (this._instance = new this());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment