From 17b5953bb8a24b0c6371a1ea6da06e082b9bdf5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20M=C3=BCller?= Date: Sun, 20 Oct 2019 16:59:48 +0200 Subject: [PATCH] fix(notifier-container): Setup notifier-container as early as possible (#144) - Setup `notifier-container` component within `constructor` instead of `ngOnInit` lifecycle hook Closes #119. --- .../lib/components/notifier-container.component.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/projects/angular-notifier/src/lib/components/notifier-container.component.ts b/projects/angular-notifier/src/lib/components/notifier-container.component.ts index a3ecd49f..95633305 100644 --- a/projects/angular-notifier/src/lib/components/notifier-container.component.ts +++ b/projects/angular-notifier/src/lib/components/notifier-container.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy } from '@angular/core'; import { Subscription } from 'rxjs'; @@ -30,7 +30,7 @@ import { NotifierNotificationComponent } from './notifier-notification.component selector: 'notifier-container', templateUrl: './notifier-container.component.html' } ) -export class NotifierContainerComponent implements OnDestroy, OnInit { +export class NotifierContainerComponent implements OnDestroy { /** * List of currently somewhat active notifications @@ -74,17 +74,14 @@ export class NotifierContainerComponent implements OnDestroy, OnInit { this.queueService = notifierQueueService; this.config = notifierService.getConfig(); this.notifications = []; - } - /** - * Component initialization lifecycle hook, connects this component to the action queue, and then handles incoming actions - */ - public ngOnInit(): void { + // Connects this component up to the action queue, then handle incoming actions this.queueServiceSubscription = this.queueService.actionStream.subscribe( ( action: NotifierAction ) => { this.handleAction( action ).then( () => { this.queueService.continue(); } ); } ); + } /**