import { Component, Input, SimpleChange, SimpleChanges } from '@angular/core';
import { Observable } from 'rxjs';
import { NgOnInit, NgOnChanges, NgOnDestroy } from '@ngcool/lifecycle';
@Component({
selector: 'app-test',
template: `
{{ onChanges$ | async | json }} <br />
{{ test$ | async | json }}
`,
})
export class TestComponent {
@Input()
test: any;
@NgOnInit()
onInit$: Observable<void>;
@NgOnChanges<TestComponent>()
onChanges$: Observable<SimpleChanges>;
@NgOnChanges<TestComponent>('test')
test$: Observable<SimpleChange>;
@NgOnDestroy()
onDestroy$: Observable<void>;
constructor() {
this.onInit$.subscribe({
next: () => console.log('on init'),
complete: () => console.log('complete on init'),
});
this.onDestroy$.subscribe({
next: () => console.log('on destroy'),
complete: () => console.log('complete destroy'),
});
}
}
POC - angular lifecycle observables (with decorators)
License
tonivj5/ng-rx-lifecycle
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
POC - angular lifecycle observables (with decorators)
Resources
License
Code of conduct
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published