Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

cedvdb/ng2AutoUnsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Usage example : When you subscribe to an observable just add .takeUntil(this._destroy$) and your subscriptions will be automatically unsubbed on destroy.

import { AutoUnsub } from 'ng2-auto-unsub/auto-unsub.component';

//...
export class TestComponent extends AutoUnsub implements OnInit {

  constructor() {
    super();
  }

  ngOnInit() {
    Observable
    .fromEvent(document, "mousemove")
    .takeUntil(this._destroy$)
    .subscribe(e => console.log(e));
  }

}

About

Angular 2 auto unsubscribe observables in components

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published