Skip to content

Instantly share code, notes, and snippets.

@YonathanMeguira
Last active August 6, 2017 23:54
Show Gist options
  • Save YonathanMeguira/23fd7f42a9cf9e9c5e0a7a4de10720ab to your computer and use it in GitHub Desktop.
Save YonathanMeguira/23fd7f42a9cf9e9c5e0a7a4de10720ab to your computer and use it in GitHub Desktop.
dataService.ts
import {Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
@Injectable()
export class Monsters{
private _monter: SubjectBehavior<string[]>;
constructor(){
// passing it an empty monster for starter
this._monster = new BehaviorSubject('');
}
selectMonster(newMonster: string){
this._monster.next(newMonster);
}
get monster(){
return this._monster.asObservable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment