Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import { Observable } from 'rxjs/Rx';
  2.  
  3. // ...
  4.  
  5. ngOnInit() {
  6. Observable.forkJoin(
  7. this.instrumentService.current,
  8. this.tuningService.tunings
  9. ).subscribe(
  10. data => {
  11. console.log(data);
  12. }
  13. );
  14. }
  15.  
  16. this.instrumentService.current.subscribe(instrument => {
  17. console.log(instrument);
  18. this.instrument = instrument;
  19. });
  20.  
  21. this.tuningService.tunings.subscribe(tunings => {
  22. console.log(tunings);
  23. this.tunings = tunings;
  24. });
  25.  
  26. private _tunings: BehaviorSubject<Tuning[]> = new BehaviorSubject([]);
  27.  
  28. /**
  29. * Class constructor.
  30. *
  31. * @param {ApiService} apiService
  32. */
  33. constructor (private apiService: ApiService) {
  34. this.getAll().subscribe(tunings => this._tunings.next(tunings));
  35. }
  36.  
  37. public get tunings() {
  38. return this._tunings.asObservable();
  39. }
  40.  
  41. public getAll(): Observable<Tuning[]> {
  42. return this.apiService.call(this.url);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement