import { TakeExercise } from './take-exercise' ; import { Component , OnInit , OnDestroy } from '@angular/core' ; import { ExerciseService } from '../../shared/exercise.service' ; import { TranslateService } from '@ngx-translate/core' ; import { Subscription } from 'rxjs' ; @ Component ( { selector : 'app-take' , templateUrl : './take.component.html' , styleUrls : [ './take.component.scss' ] } ) export class TakeComponent implements OnInit , OnDestroy { task = 'take' ; takeCode = `
  const intervalCount = interval(1000);
  intervalCount.pipe(
    take(5)
  ).subscribe(x => console.log(x));

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