From 16a9fce0e104a38371a9e5a567ec611ae3fc7f33 Mon Sep 17 00:00:00 2001 From: ys9693 Date: Sun, 19 Jan 2020 13:50:02 +0200 Subject: Catalog alignment Issue-ID: SDC-2724 Signed-off-by: ys9693 Change-Id: I52b4aacb58cbd432ca0e1ff7ff1f7dd52099c6fe --- .../src/app/services/event-listener-service.ts | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'catalog-ui/src/app/services/event-listener-service.ts') diff --git a/catalog-ui/src/app/services/event-listener-service.ts b/catalog-ui/src/app/services/event-listener-service.ts index 360edad700..2d3c4a6fc8 100644 --- a/catalog-ui/src/app/services/event-listener-service.ts +++ b/catalog-ui/src/app/services/event-listener-service.ts @@ -23,22 +23,21 @@ 'use strict'; import * as _ from "lodash"; import {Dictionary} from "../utils/dictionary/dictionary"; +import {Injectable} from "@angular/core"; -interface IEventListenerService { - -} interface ICallbackData { - callback:Function; - args:any[]; + callback: Function; + args: any[]; } -export class EventListenerService implements IEventListenerService { +@Injectable() +export class EventListenerService { - public observerCallbacks:Dictionary = new Dictionary>(); + public observerCallbacks: Dictionary = new Dictionary>(); //register an observer + callback - public registerObserverCallback = (eventName:string, callback:Function, ...args) => { + public registerObserverCallback = (eventName: string, callback: Function, ...args) => { let callbackData = { callback: callback, args: args @@ -62,11 +61,11 @@ export class EventListenerService implements IEventListenerService { }; //unregister an observer - public unRegisterObserver = (eventName:string, callbackFunc?:Function) => { + public unRegisterObserver = (eventName: string, callbackFunc?: Function) => { if (this.observerCallbacks.containsKey(eventName)) { - let callbacks: ICallbackData[] = this.observerCallbacks.getValue(eventName); - if(callbacks.length === 1) { + let callbacks: ICallbackData[] = this.observerCallbacks.getValue(eventName); + if (callbacks.length === 1) { this.observerCallbacks.remove(eventName); } else { let filterCallbacks = _.filter(callbacks, (callBackObj) => { @@ -74,13 +73,12 @@ export class EventListenerService implements IEventListenerService { }); this.observerCallbacks.setValue(eventName, filterCallbacks); } - } }; - public notifyObservers = function (eventName:string, ...args) { - _.forEach(this.observerCallbacks.getValue(eventName), (callbackData:ICallbackData) => { - callbackData.callback(...args); - }); + public notifyObservers = function (eventName: string, ...args) { + _.forEach(this.observerCallbacks.getValue(eventName), (callbackData: ICallbackData) => { + callbackData.callback(...args); + }); }; } -- cgit 1.2.3-korg