Skip to content

Commit 17b5953

Browse files
authored
fix(notifier-container): Setup notifier-container as early as possible (#144)
- Setup `notifier-container` component within `constructor` instead of `ngOnInit` lifecycle hook Closes #119.
1 parent f838719 commit 17b5953

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

projects/angular-notifier/src/lib/components/notifier-container.component.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy } from '@angular/core';
22

33
import { Subscription } from 'rxjs';
44

@@ -30,7 +30,7 @@ import { NotifierNotificationComponent } from './notifier-notification.component
3030
selector: 'notifier-container',
3131
templateUrl: './notifier-container.component.html'
3232
} )
33-
export class NotifierContainerComponent implements OnDestroy, OnInit {
33+
export class NotifierContainerComponent implements OnDestroy {
3434

3535
/**
3636
* List of currently somewhat active notifications
@@ -74,17 +74,14 @@ export class NotifierContainerComponent implements OnDestroy, OnInit {
7474
this.queueService = notifierQueueService;
7575
this.config = notifierService.getConfig();
7676
this.notifications = [];
77-
}
7877

79-
/**
80-
* Component initialization lifecycle hook, connects this component to the action queue, and then handles incoming actions
81-
*/
82-
public ngOnInit(): void {
78+
// Connects this component up to the action queue, then handle incoming actions
8379
this.queueServiceSubscription = this.queueService.actionStream.subscribe( ( action: NotifierAction ) => {
8480
this.handleAction( action ).then( () => {
8581
this.queueService.continue();
8682
} );
8783
} );
84+
8885
}
8986

9087
/**

0 commit comments

Comments
 (0)