NetanelBasal
4/10/2017 - 2:24 PM

takeuntil.ts

import TakeUntilDestroy from "angular2-take-until-destroy";

@Component({
  selector: 'app-inbox',
  templateUrl: './inbox.component.html'
})
@TakeUntilDestroy
export class InboxComponent {
  componentDestroy;
  constructor( ) {
    const timer$ = Observable.interval(1000)
      .takeUntil(this.componentDestroy())
      .subscribe(val => console.log(val))
    
    const timer2$ = Observable.interval(2000)
      .takeUntil(this.componentDestroy())
      .subscribe(val => console.log(val))
  }
}