瀏覽代碼

minor update to prevent redudant instantiation

Enzo 1 年之前
父節點
當前提交
e0d7096dfe
共有 1 個文件被更改,包括 3 次插入7 次删除
  1. 3 7
      services/message-auditor.service.ts

+ 3 - 7
services/message-auditor.service.ts

@@ -8,6 +8,7 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
     private settings: MessageSynchronisationServiceSetting
     private sourceSrc: LoggingService = new LoggingService()
     private targetSrc: LoggingService = new LoggingService()
+    private missingMessageSubject: Subject<MessageLog> = new Subject()
 
     /* Set up the targets or points of synchronization. This is where it will register the 2 different location of 
     the data to be synchronized */
@@ -21,25 +22,20 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
     and return the missing data, which will then be passed into the targeted subject stream as specified by the
     respective client. They can choose how they want to handle the missing messages returned. */
     public subscribe(obsTrigger: Observable<ErrorTrigger>): Observable<MessageLog> {
-        // Create a subject as a means to return the missing messages if there's any.
-        let msg: Subject<MessageLog> = new Subject()
-
         // Subsribe to the errorTrigger obs to listen to any notification.
         obsTrigger.subscribe({
             next: obsTrigger => {
                 console.log(obsTrigger.message)// just checking the message
-
                 let missingMsg: Observable<MessageLog> = this.synchronize()
                 missingMsg.subscribe({
                     next: element => {
-                        msg.next(element)
+                        this.missingMessageSubject.next(element)
                         console.log(`AuditService: Returning missing messages ${element.appData.msgId} ....`)
                     }
                 })
             }
         })
-        let result: Observable<MessageLog> = msg.asObservable()
-        return result
+        return this.missingMessageSubject
     }
 
     /* This is where the 'synching' operation takes place. */