ng2-auto-unsub

1.0.4 • Public • Published

Usage example : When you subscribe to an observable just add takeUntil(.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));
  }

}

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i ng2-auto-unsub

      Weekly Downloads

      3

      Version

      1.0.4

      License

      ISC

      Last publish

      Collaborators

      • cedvdb