gt-unsubscribe-on-detroy
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

gt-unsubscribe-on-detroy

Unsubscribe Angular component when OnDetroy.ngOnDetroy() was call. ##installation

npm install --save gt-unsubscribe-on-detroy

##Usage

import { untilDestroyed } from 'gt-unsubscribe-on-detroy';

@Component({
  selector: 'app-content',
  templateUrl: './content.component.html'
})
export class ContentComponent implements OnInit, OnDestroy {
  ngOnInit() {
    interval(1000)
      .pipe(unsubscribeOnDetroy(this)) //Typesafe!! this must be instance of OnDestroy
      .subscribe(e => console.log(e));
      
      interval(1000)
      .pipe(unsubscribeOnDetroy(this)) //Can use many times as you want.
      .subscribe(e => console.log(e));
  }
  
  ngOnDestroy() {
    // it will be unsunscribe by Subject.takeUtil after this method call
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i gt-unsubscribe-on-detroy

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

6.17 kB

Total Files

9

Last publish

Collaborators

  • pramoth