Skip to content

Commit f251299

Browse files
committed
fix: fixed aot error with forRoot method
1 parent e5ca0f1 commit f251299

File tree

9 files changed

+50
-47
lines changed

9 files changed

+50
-47
lines changed

index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"docs:generate": "npm run docs:clean && typedoc --out docs --excludePrivate --mode file --exclude \"**/*+(index|spec|entry).ts\" ./src",
1919
"docs:clean": "del-cli docs/"
2020
},
21-
"typings": "./angular-client.d.ts",
21+
"typings": "./xivapi-client.d.ts",
2222
"author": "Supamiu",
2323
"repository": {
2424
"type": "git",

public_api.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from './index';
1+
// Public classes.
2+
export * from './src/xivapi-client';

src/xivapi-client.module.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
1+
import { ModuleWithProviders, NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { XivapiService } from './xivapi.service';
4-
import { HttpClientModule } from '@angular/common/http';
5-
6-
/**
7-
* @hidden
8-
*/
9-
export const XIVAPI_KEY: InjectionToken<string> = new InjectionToken('XIVAPI_KEY');
4+
import { HttpClient, HttpClientModule } from '@angular/common/http';
5+
import { XivapiServiceFactory } from './xivapi-service-factory';
106

117
@NgModule({
128
imports: [
@@ -21,8 +17,11 @@ export class XivapiClientModule {
2117
return {
2218
ngModule: XivapiClientModule,
2319
providers: [
24-
XivapiService,
25-
{provide: XIVAPI_KEY, useValue: key}
20+
{
21+
provide: XivapiService,
22+
useFactory: XivapiServiceFactory,
23+
deps: [key, HttpClient]
24+
}
2625
]
2726
};
2827
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { XivapiClientModule, XIVAPI_KEY } from './xivapi-client.module';
1+
export { XivapiClientModule } from './xivapi-client.module';
22
export { XivapiService } from './xivapi.service';
33
export * from './model/index';

src/xivapi-service-factory.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { XivapiService } from './xivapi.service';
2+
import { HttpClient } from '@angular/common/http';
3+
4+
export function XivapiServiceFactory(key: string, http: HttpClient): XivapiService {
5+
return new XivapiService(key, http);
6+
}

src/xivapi.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Inject, Injectable } from '@angular/core';
1+
import { Inject, Injectable, Optional } from '@angular/core';
22
import { HttpClient, HttpParams } from '@angular/common/http';
33
import { Observable } from 'rxjs';
44
import {
@@ -11,7 +11,6 @@ import {
1111
XivapiRequestOptions,
1212
XivapiSearchOptions
1313
} from './model';
14-
import { XIVAPI_KEY } from './xivapi-client.module';
1514
import { CharacterResponse, CharacterVerification } from './model/schema/character';
1615

1716
@Injectable()
@@ -22,7 +21,7 @@ export class XivapiService {
2221
*/
2322
public static readonly API_BASE_URL: string = 'https://xivapi.com';
2423

25-
constructor(@Inject(XIVAPI_KEY) protected readonly apiKey: string, private http: HttpClient) {
24+
constructor(@Inject('XIVAPI_KEY') protected readonly apiKey: string, private http: HttpClient) {
2625
}
2726

2827
/**

test/xivapi.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TestBed } from '@angular/core/testing';
2-
import { SearchIndex, XivapiService } from '../src';
2+
import { SearchIndex, XivapiService } from '../src/xivapi-client';
33
import { HttpClientTestingModule, HttpTestingController, TestRequest } from '@angular/common/http/testing';
44
import { HttpClient } from '@angular/common/http';
55

tsconfig-build.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
{
2-
"compilerOptions": {
3-
"baseUrl": ".",
4-
"declaration": true,
5-
"experimentalDecorators": true,
6-
"strict": true,
7-
"module": "es2015",
8-
"moduleResolution": "node",
9-
"outDir": "dist",
10-
"rootDir": ".",
11-
"sourceMap": true,
12-
"inlineSources": true,
13-
"target": "es2015",
14-
"skipLibCheck": true,
15-
"lib": [
16-
"es2015",
17-
"dom"
18-
]
19-
},
20-
"files": [
21-
"public_api.ts",
22-
"node_modules/zone.js/dist/zone.js.d.ts"
23-
],
24-
"angularCompilerOptions": {
25-
"skipTemplateCodegen": true,
26-
"annotateForClosureCompiler": true,
27-
"strictMetadataEmit": true,
28-
"flatModuleOutFile": "xivapi-client.js",
29-
"flatModuleId": "@xivapi/angular-client"
30-
}
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"declaration": true,
5+
"experimentalDecorators": true,
6+
"strict": true,
7+
"module": "es2015",
8+
"moduleResolution": "node",
9+
"outDir": "dist",
10+
"rootDir": ".",
11+
"sourceMap": true,
12+
"inlineSources": true,
13+
"target": "es2015",
14+
"skipLibCheck": true,
15+
"lib": [
16+
"es2015",
17+
"dom"
18+
]
19+
},
20+
"files": [
21+
"public_api.ts",
22+
"node_modules/zone.js/dist/zone.js.d.ts"
23+
],
24+
"angularCompilerOptions": {
25+
"skipTemplateCodegen": true,
26+
"annotateForClosureCompiler": true,
27+
"strictMetadataEmit": true,
28+
"flatModuleOutFile": "xivapi-client.js",
29+
"flatModuleId": "@xivapi/angular-client"
30+
}
3131
}

0 commit comments

Comments
 (0)