Created
July 10, 2020 02:49
-
-
Save benhickson/203493c96ff58c7473aaf02571dc072c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject } from 'rxjs'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class PlayerService { | |
private currentPlayerSource = new BehaviorSubject(0); // 0 is the default value | |
currentPlayer = this.currentPlayerSource.asObservable(); | |
constructor() { } | |
changeCurrentPlayer(player: number): void { | |
this.currentPlayerSource.next(player); | |
console.log('current player id:', player); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment