0.1.13 • Published 1 year ago

ngx-until-destroy v0.1.13

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ngx-until-destroy

Reduce your boilerplate code and unsubscribe your RxJS observables with ease - within your Angular components.

Getting started

  1. npm i ngx-until-destroy
  2. Decorate your component with @WithDestroy$()
  3. Use .pipe(untilDestroy$(this)) before .subscribe(...)

And voilà, you don't have to take care of unsubscribing anymore. Your subscription exists as long as your component exists.

Example

@WithDestroy$()
@Component({...})
export class ExampleComponent {
  ...
  someObservable$.pipe(untilDestroy$(this)).subscribe(...)
}

How it works

What happens in the background is pretty simple.

@WithDestroy$() decorates your component in a way, that it will have a class variable named $destroy, it's a simple RxJS Subject, which emits a new value, when the component is destroyed - by extending ngOnDestroy().

untilDestroy$(this) is simply returning takeUntil(this.destroy$), so your subscription is going to be active just until your component is destroyed. No need for extra boilerplate code or unsubscribing manually.

Contributing

This project was generated with Angular CLI version 14.0.1.

Feel free to clone the project, have a look at it, make changes and / or open a Pull Request.

In case you have any questions, problems or feature requests, feel free to open an issue on GitHub.

0.1.12

1 year ago

0.1.13

1 year ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago