import { ExerciseService } from '../../shared/exercise.service' ; import { Component , OnInit , OnDestroy } from '@angular/core' ; import { ForkJoinExercise } from './fork-join-exercise' ; import { TranslateService } from '@ngx-translate/core' ; import { Subscription } from 'rxjs' ; @ Component ( { selector : 'app-fork-join' , templateUrl : './fork-join.component.html' , styleUrls : [ './fork-join.component.scss' ] } ) export class ForkJoinComponent implements OnInit , OnDestroy { exerciseTitle = 'fork-join' ; forkJoinCode = `
  const observable = forkJoin([
    foo: of(1,2,3,4),
    bar: of(1,2)
  ]).subscribe(x => console.log(x));

  // Logs:
  // [ 4, 2 ]
  ` ; currentLanguage = '' ; onLangChangeSubscription : Subscription ; constructor ( private exerciseService , private translateService ) { } ngOnInit ( ) { this . exerciseService . newExercise ( new ForkJoinExercise ( ) ) ; this . currentLanguage = this . translateService . currentLang ; this . onLangChangeSubscription = this . translateService . onLangChange . subscribe ( { next : ( ) => { this . currentLanguage = this . translateService . currentLang ; } } ) ; } ngOnDestroy ( ) { this . onLangChangeSubscription . unsubscribe ( ) ; } }