Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smnbbrv/ngx-rx-collector
Angular 6+ garbage collector for RxJS subscriptions.
https://github.com/smnbbrv/ngx-rx-collector
angular2 ng2-rx-collector rxjs-subscriptions
Last synced: about 2 months ago
JSON representation
Angular 6+ garbage collector for RxJS subscriptions.
- Host: GitHub
- URL: https://github.com/smnbbrv/ngx-rx-collector
- Owner: smnbbrv
- Created: 2016-12-07T17:02:10.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-21T09:24:37.000Z (almost 5 years ago)
- Last Synced: 2024-11-03T12:07:08.295Z (2 months ago)
- Topics: angular2, ng2-rx-collector, rxjs-subscriptions
- Language: TypeScript
- Homepage:
- Size: 52.7 KB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deprecated
Angular 2+ garbage collector for RxJS subscriptions.
Benefits:
- Clean, beautiful code
- One property for all component's observables## Installation
```sh
npm i -S ngx-rx-collector
```For v1 and v2 see corresponding branches
## Usage
Use the pipe-able operator `untilDestroyed` and pass there your component instance. That is pretty much it.
If you use AoT build (which is enabled by default) you must have at least empty `ngOnDestroy` on your component.
If you don't use AoT build then simply call `ngxRxCollectorDisableAoTWarning()` in your `main.ts`. No `ngOnDestroy` required in this case.
## Example
AoT build + no ngOnDestroy logic:
```ts
import { Component } from '@angular/core';
import { Collectable } from 'ngx-rx-collector';
import { interval } from 'rxjs/observable/interval';@Component({
template: 'Ticking bomb'
})
export class TestpageComponent {ngOnInit() {
interval(1000).pipe(untilDestroyed(this)).subscribe(console.log.bind(console));
}ngOnDestroy() {}
}
```Non-AoT build + no ngOnDestroy logic:
```ts
import { Component } from '@angular/core';
import { Collectable } from 'ngx-rx-collector';
import { interval } from 'rxjs/observable/interval';@Component({
template: 'Ticking bomb'
})
export class TestpageComponent {ngOnInit() {
interval(1000).pipe(untilDestroyed(this)).subscribe(console.log.bind(console));
}}
```Any build + ngOnDestroy logic:
```ts
import { Component } from '@angular/core';
import { Collectable } from 'ngx-rx-collector';
import { interval } from 'rxjs/observable/interval';@Component({
template: 'Ticking bomb'
})
export class TestpageComponent {ngOnInit() {
interval(1000).pipe(untilDestroyed(this)).subscribe(console.log.bind(console));
}ngOnDestroy() {
console.log('destroyed')
}}
```## License
MIT