Skip to content

Class decorator that will automatically unsubscribe from observable subscriptions when the component is destroyed without implement ngOnDestroy lifecycle.

Notifications You must be signed in to change notification settings

aparzi/ngx-ap-autounsubscribe

Repository files navigation

NgxApAutounsubscribe

This project is compatible with Angular 13+ versions.

Class decorator that will automatically unsubscribe from observable subscriptions when the component is destroyed without implement ngOnDestroy lifecycle.

Installation

Install this package with npm, with following command:
npm install ngx-ap-autounsubscribe

Usage

import { AutoUnsubscribe } from "ngx-ap-auto-unsubscribe";

@AutoUnsubscribe()
export class ExampleComponent {
  testSubscription: Subscription;

  ngOnInit() {
    this.testSubscription = Observable.interval.subscribe(data => // do something);
  }
}

Options

Option Description Default value
arrayName unsubscribe from subscriptions only in specified array undefined
blacklist an array of properties to exclude undefined
event a name of event callback to execute on undefined

Start Local Environment

Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.

Contributing

To get more help on this project use go check out the NgxApAutounsubscribe page.

About

Class decorator that will automatically unsubscribe from observable subscriptions when the component is destroyed without implement ngOnDestroy lifecycle.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •