From 846955eea2562e15d753269437d637ef2852faf7 Mon Sep 17 00:00:00 2001 From: Sergey Akopkokhyants Date: Thu, 22 Dec 2016 21:47:21 +0200 Subject: [PATCH] fix(): Added toastyServiceFactory to initialise the ToastyService --- index.ts | 9 ++++++--- package.json | 18 +++++++++--------- src/toasty.service.ts | 9 +++++++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/index.ts b/index.ts index 98b024b..ec00864 100644 --- a/index.ts +++ b/index.ts @@ -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 }; } } \ No newline at end of file diff --git a/package.json b/package.json index d95783a..37a0f90 100644 --- a/package.json +++ b/package.json @@ -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", @@ -61,7 +61,7 @@ "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", @@ -69,7 +69,7 @@ "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": { diff --git a/src/toasty.service.ts b/src/toasty.service.ts index 73cd6b5..0eaaa16 100644 --- a/src/toasty.service.ts +++ b/src/toasty.service.ts @@ -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; @@ -23,7 +24,8 @@ export interface ToastOptions { /** * Structrure of Toast */ -export interface ToastData { +@Injectable() +export class ToastData { id: number; title: string; msg: string; @@ -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