From e04e06451527bf2d08d21424aafdf0b430f0c810 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 6 Apr 2018 15:33:53 -0400 Subject: [PATCH] move broadcaster to jslib --- jslib | 2 +- src/app/app.component.ts | 2 +- src/app/services/broadcaster.service.ts | 33 ------------------- src/app/services/services.module.ts | 2 +- src/app/vault/vault.component.ts | 2 +- .../desktopRendererMessaging.service.ts | 2 +- 6 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 src/app/services/broadcaster.service.ts diff --git a/jslib b/jslib index 0b9c2f51..5d66ede2 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 0b9c2f518d72b3b3a6bcf97f97bc7dfa15b4e153 +Subproject commit 5d66ede2ea1e73ba0ad8bf949bd74992e7a78582 diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6dbb1d3b..d59e1109 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -25,7 +25,7 @@ import { PasswordGeneratorHistoryComponent } from './vault/password-generator-hi import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; -import { BroadcasterService } from './services/broadcaster.service'; +import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; import { AuthService } from 'jslib/abstractions/auth.service'; import { CipherService } from 'jslib/abstractions/cipher.service'; diff --git a/src/app/services/broadcaster.service.ts b/src/app/services/broadcaster.service.ts deleted file mode 100644 index fe747e7b..00000000 --- a/src/app/services/broadcaster.service.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable() -export class BroadcasterService { - subscribers: Map any> = new Map any>(); - - send(message: any, id?: string) { - if (id != null) { - if (this.subscribers.has(id)) { - this.subscribers.get(id)(message); - } - return; - } - - this.subscribers.forEach((value) => { - value(message); - }); - } - - subscribe(id: string, messageCallback: (message: any) => any) { - if (this.subscribers.has(id)) { - return; - } - - this.subscribers.set(id, messageCallback); - } - - unsubscribe(id: string) { - if (this.subscribers.has(id)) { - this.subscribers.delete(id); - } - } -} diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index 0ba68a6c..2765a8a2 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -15,7 +15,7 @@ import { I18nService } from '../../services/i18n.service'; import { LogService } from '../../services/log.service'; import { AuthGuardService } from 'jslib/angular/services/auth-guard.service'; -import { BroadcasterService } from './broadcaster.service'; +import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; import { ValidationService } from 'jslib/angular/services/validation.service'; import { Analytics } from 'jslib/misc/analytics'; diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index 5c4c8582..5eae94ad 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -21,7 +21,7 @@ import { Angulartics2 } from 'angulartics2'; import { ModalComponent } from '../modal.component'; -import { BroadcasterService } from '../services/broadcaster.service'; +import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; import { AddEditComponent } from './add-edit.component'; import { AttachmentsComponent } from './attachments.component'; diff --git a/src/services/desktopRendererMessaging.service.ts b/src/services/desktopRendererMessaging.service.ts index 2944696c..047516ac 100644 --- a/src/services/desktopRendererMessaging.service.ts +++ b/src/services/desktopRendererMessaging.service.ts @@ -2,7 +2,7 @@ import { ipcRenderer } from 'electron'; import { MessagingService } from 'jslib/abstractions/messaging.service'; -import { BroadcasterService } from '../app/services/broadcaster.service'; +import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; export class DesktopRendererMessagingService implements MessagingService { constructor(private broadcasterService: BroadcasterService) {