Skip to content

Commit

Permalink
fix(): Added toastyServiceFactory to initialise the ToastyService
Browse files Browse the repository at this point in the history
  • Loading branch information
akserg committed Dec 22, 2016
1 parent 29e376c commit 846955e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
9 changes: 6 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ export * from './src/toasty.component';

import { ToastyComponent } from './src/toasty.component';
import { ToastComponent } from './src/toast.component';
import { ToastyConfig, ToastyService } from './src/toasty.service';
import { ToastyService, toastyServiceFactory } from './src/toasty.service';

export let providers = [{ provide: ToastyService, useFactory: toastyServiceFactory }];

@NgModule({
declarations: [ToastComponent, ToastyComponent],
exports : [ToastComponent, ToastyComponent]
exports : [ToastComponent, ToastyComponent],
providers: providers
})
export class ToastyModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: ToastyModule,
providers: [ToastyConfig, ToastyService]
providers: providers
};
}
}
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"@angular/core": "^2.0.0"
},
"devDependencies": {
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/compiler-cli": "2.1.2",
"@angular/core": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/platform-server": "2.1.2",
"@angular/common": "^2.1.2",
"@angular/compiler": "^2.1.2",
"@angular/compiler-cli": "^2.1.2",
"@angular/core": "^2.1.2",
"@angular/platform-browser": "^2.1.2",
"@angular/platform-browser-dynamic": "^2.1.2",
"@angular/platform-server": "^2.1.2",
"@types/hammerjs": "2.0.33",
"@types/jasmine": "2.5.37",
"@types/node": "6.0.46",
Expand All @@ -61,15 +61,15 @@
"karma-webpack": "^1.8.0",
"loader-utils": "~0.2.16",
"reflect-metadata": "0.1.8",
"rxjs": "5.0.0-beta.12",
"rxjs": "^5.0.1",
"semantic-release": "4.3.5",
"source-map-loader": "0.1.5",
"ts-helpers": "1.1.2",
"tslint": "3.15.1",
"tslint-loader": "2.1.5",
"typescript": "2.0.10",
"webpack": "2.1.0-beta.25",
"zone.js": "0.6.26"
"zone.js": "^0.7.2"
},
"config": {
"commitizen": {
Expand Down
9 changes: 7 additions & 2 deletions src/toasty.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { Observable } from 'rxjs/Observable';
/**
* Options to configure specific Toast
*/
export interface ToastOptions {
@Injectable()
export class ToastOptions {
title: string;
msg?: string;
showClose?: boolean;
Expand All @@ -23,7 +24,8 @@ export interface ToastOptions {
/**
* Structrure of Toast
*/
export interface ToastData {
@Injectable()
export class ToastData {
id: number;
title: string;
msg: string;
Expand Down Expand Up @@ -60,6 +62,9 @@ export class ToastyConfig {
theme: string = 'default';
}

export function toastyServiceFactory(): ToastyService {
return new ToastyService(new ToastyConfig());
}

/**
* Toasty service helps create different kinds of Toasts
Expand Down

0 comments on commit 846955e

Please sign in to comment.