Guest User

Untitled

a guest
Aug 10th, 2018
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // in queue.component.html
  2. <button class="ws-shift" (click)="test()" >Test</button>
  3.  
  4.  
  5. //in queue.component.ts
  6. export class QueueComponent implements OnInit {
  7.  
  8. constructor(private playerHanlder: PlayerHanlder) { }
  9.  
  10. ngOnInit() {
  11. }
  12.  
  13. test(){
  14. // when I click the button, nothing gets printed out
  15. this.playerHanlder.tracks$.subscribe(t=>console.log(t))
  16. }
  17. }
  18.  
  19. // in playerhandler.ts
  20.  
  21. @Injectable({
  22. providedIn: "root"
  23. })
  24. export class PlayerHanlder {
  25. isPlaying: boolean = false;
  26. index: number;
  27. tracks$ = new ReplaySubject<any>();
  28.  
  29. constructor(
  30. private playerService: PlayerService,
  31. private deezer: DeezerService
  32. ) { }
  33.  
  34. initTracks(tracks): void {
  35. this.tracks$.next(tracks);
  36. this.playerService.init(tracks);
  37. }
RAW Paste Data