Skip to content

Commit 139d43c

Browse files
M4R1KUitsdevdom
authored andcommitted
fix(notifier): Fix circular dependency issues of injection tokens (#124)
1 parent 1bff46d commit 139d43c

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

src/lib/src/components/notifier-container.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { By } from '@angular/platform-browser';
22
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
33
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
44

5-
import { NotifierConfigToken } from '../notifier.module';
5+
import { NotifierConfigToken } from '../notifier-token';
66
import { NotifierAction } from '../models/notifier-action.model';
77
import { NotifierConfig } from '../models/notifier-config.model';
88
import { NotifierQueueService } from '../services/notifier-queue.service';

src/lib/src/components/notifier-notification.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DebugElement, Component, ViewChild, NO_ERRORS_SCHEMA, TemplateRef } fro
22
import { By } from '@angular/platform-browser';
33
import { ComponentFixture, fakeAsync, TestBed, tick, async } from '@angular/core/testing';
44

5-
import { NotifierConfigToken } from '../notifier.module';
5+
import { NotifierConfigToken } from '../notifier-token';
66
import { NotifierAnimationData } from '../models/notifier-animation.model';
77
import { NotifierNotification } from '../models/notifier-notification.model';
88
import { NotifierConfig } from '../models/notifier-config.model';

src/lib/src/notifier-token.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { NotifierConfig, NotifierOptions } from './models/notifier-config.model';
2+
import { InjectionToken } from '@angular/core';
3+
4+
// tslint:disable variable-name
5+
6+
/**
7+
* Injection Token for notifier options
8+
*/
9+
export const NotifierOptionsToken: InjectionToken<NotifierOptions>
10+
= new InjectionToken<NotifierOptions>( '[angular-notifier] Notifier Options' );
11+
12+
/**
13+
* Injection Token for notifier configuration
14+
*/
15+
export const NotifierConfigToken: InjectionToken<NotifierConfig>
16+
= new InjectionToken<NotifierConfig>( '[anuglar-notifier] Notifier Config' );
17+
18+
// tslint:enable variable-name
19+

src/lib/src/notifier.module.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,7 @@ import { NotifierConfig, NotifierOptions } from './models/notifier-config.model'
77
import { NotifierAnimationService } from './services/notifier-animation.service';
88
import { NotifierQueueService } from './services/notifier-queue.service';
99
import { NotifierService } from './services/notifier.service';
10-
11-
// tslint:disable variable-name
12-
13-
/**
14-
* Injection Token for notifier options
15-
*/
16-
export const NotifierOptionsToken: InjectionToken<NotifierOptions>
17-
= new InjectionToken<NotifierOptions>( '[angular-notifier] Notifier Options' );
18-
19-
/**
20-
* Injection Token for notifier configuration
21-
*/
22-
export const NotifierConfigToken: InjectionToken<NotifierConfig>
23-
= new InjectionToken<NotifierConfig>( '[anuglar-notifier] Notifier Config' );
24-
25-
// tslint:enable variable-name
10+
import { NotifierConfigToken, NotifierOptionsToken } from './notifier-token';
2611

2712
/**
2813
* Factory for a notifier configuration with custom options

src/lib/src/services/notifier.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { inject, TestBed } from '@angular/core/testing';
22

3-
import { NotifierConfigToken } from '../notifier.module';
3+
import { NotifierConfigToken } from '../notifier-token';
44
import { NotifierConfig } from '../models/notifier-config.model';
55
import { NotifierNotificationOptions } from '../models/notifier-notification.model';
66
import { NotifierAction } from '../models/notifier-action.model';

src/lib/src/services/notifier.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Inject, Injectable, forwardRef } from '@angular/core';
33
import { NotifierConfig } from './../models/notifier-config.model';
44
import { NotifierNotificationOptions } from './../models/notifier-notification.model';
55
import { NotifierQueueService } from './notifier-queue.service';
6-
import { NotifierConfigToken } from './../notifier.module';
6+
import { NotifierConfigToken } from './../notifier-token';
77

88
/**
99
* Notifier service
@@ -33,7 +33,7 @@ export class NotifierService {
3333
*/
3434
public constructor(
3535
notifierQueueService: NotifierQueueService,
36-
@Inject( forwardRef( () => NotifierConfigToken ) ) config: NotifierConfig // The forwardRef is (sadly) required here
36+
@Inject(NotifierConfigToken) config: NotifierConfig
3737
) {
3838
this.queueService = notifierQueueService;
3939
this.config = config;

0 commit comments

Comments
 (0)