Skip to content

Commit

Permalink
Small fixes for npm
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenCodeforges committed May 6, 2017
1 parent ce54538 commit 07a54e2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ng-gapi",
"version": "0.0.36",
"version": "0.0.39",
"description": "Angular 2 Google api module",
"main": "components.js",
"typings": "lib/index",
"main": "./lib/index.js",
"typings": "./lib/index",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -30,16 +30,14 @@
"url": "https://github.com/rubenCodeforges/angular2-google-api/issues"
},
"homepage": "https://github.com/rubenCodeforges/angular2-google-api#readme",
"devDependencies": {
"typescript": "^2.2.2",
"dependencies": {
"@types/gapi": "0.0.31",
"@types/gapi.auth2": "0.0.35"
},
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/http": "^4.0.0",
"rxjs": "^5.3.0"
"devDependencies": {
"@angular/core": "^4.1.1",
"rxjs": "^5.3.1",
"typescript": "^2.2.2",
"zone.js": "^0.8.10"
}
}
}
6 changes: 1 addition & 5 deletions src/GoogleApiModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ export class GoogleApiModule {
return {
ngModule: GoogleApiModule,
providers: [
GoogleApiService,
{
provide: GoogleApiService,
useFactory: GoogleApiService.factory,
deps: [
apiConfig
]
useFactory: () => GoogleApiService.factory(apiConfig),
},
{
provide: GoogleAuthService,
Expand Down
18 changes: 11 additions & 7 deletions src/GoogleApiService.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {Observable} from "rxjs";
import {Injectable} from "@angular/core";
import {GoogleApiConfig} from "./config/GoogleApiConfig";
import {GoogleApiConfig, GapiInitConfigs} from "./config/GoogleApiConfig";

@Injectable()
export class GoogleApiService {
private readonly gapiUrl: string = 'https://apis.google.com/js/platform.js';
private isLoaded: boolean = false;
private config: GoogleApiConfig;

public static factory(apiConfig: GoogleApiConfig) {
return new GoogleApiService(apiConfig);
public static factory(configs: GapiInitConfigs) {
return new GoogleApiService(configs);
}

constructor(config: GoogleApiConfig) {
this.config = config;
constructor(config: GapiInitConfigs) {
this.config = new GoogleApiConfig(config);
this.loadGapi();
}

Expand All @@ -25,8 +25,12 @@ export class GoogleApiService {
this.loadGapi().subscribe(callback);
}

public getConfig(): GoogleApiConfig {
return this.config;
}

private loadGapi(): Observable<void> {
return Observable.create((observer) => {
return Observable.create((observer: any) => {
let node = document.createElement('script');
node.src = this.gapiUrl;
node.type = 'text/javascript';
Expand All @@ -39,4 +43,4 @@ export class GoogleApiService {
};
});
}
}
}

0 comments on commit 07a54e2

Please sign in to comment.