Observable lifecycle hooks
In Angular, you can use RxJS to observe lifecycle hooks.
To observe lifecycle hooks you can use push next event ReplaySubject
when a new value arrived.
@Component({ /*...*/})export class TabsComponent implements AfterContentInit { @ContentChildren(TabComponent) tabsSelector: QueryList<TabComponent>;
private contentInit$ = new ReplaySubject<void>(1); tabs$ = this.contentInit$.pipe( map(() => this.tabsSelector.toArray()), switchMap((tabs) => this.tabsSelector.changes.pipe(startWith(tabs))), );
ngAfterContentInit() { this.contentInit$.next(); this.contentInit$.complete(); }}