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));
  }

}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    2
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    1

Package Sidebar

Install

npm i ng2-auto-unsub

Weekly Downloads

3

Version

1.0.4

License

ISC

Last publish

Collaborators

  • cedvdb