Enzo 1 year ago
parent
commit
6e4de77c31
2 changed files with 11 additions and 24 deletions
  1. 3 16
      services/synchronization.service.ts
  2. 8 8
      test/test3a.ts

+ 3 - 16
services/synchronization.service.ts

@@ -11,26 +11,13 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
     private sourceSrc: LoggingService = new LoggingService()
     private targetSrc: LoggingService = new LoggingService()
 
-    public async init(settings: MessageSynchronisationServiceSetting): Promise<void> {
+    public  init(settings: MessageSynchronisationServiceSetting): void {
         this.settings = settings;
-        // Wrap promise so that init must be instantiated with resolve before proceeding with subscribe method
-        let promiseInit: Promise<void> = new Promise((resolve, reject) => {
-            this.sourceSrc.init(settings.incomingSource).then((data) => {
-                if (!data) reject()
-            }).then(() => {
-                this.targetSrc.init(settings.target).then((data) => {
-                    if (!data) reject()
-                    resolve()
-                })
-            })
-
-        })
-        return promiseInit
     }
 
     // Incoming obstriger serves as a trigger point to perform another synchronization
     public subscribe(obsTrigger: Observable<string>): Observable<BaseMessage> {
-        let msg : Subject<BaseMessage> = new Subject()
+        let msg: Subject<BaseMessage> = new Subject()
         obsTrigger.subscribe({
             next: obs => {
                 let missingMsg = this.dataConversion()
@@ -42,7 +29,7 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
             }
         })
         // trigger by timer
-        if(!obsTrigger) {
+        if (!obsTrigger) {
             this.dataConversion()
         }
         let result: Observable<BaseMessage> = msg.asObservable()

+ 8 - 8
test/test3a.ts

@@ -124,12 +124,12 @@ function initializeData() {
 
 initializeData()
 
-source_synchronize.init(settings).then(() => {
-    let sync = source_synchronize.subscribe(triggerSync)
-    sync.subscribe({
-        next: (msgToBeSynched) => {
-            // console.log(`synching ... ${msgToBeSynched.header.messageID}`)
-            target_payload_subject.next(msgToBeSynched)
-        }
-    })
+source_synchronize.init(settings)
+let sync = source_synchronize.subscribe(triggerSync)
+sync.subscribe({
+    next: (msgToBeSynched) => {
+        // console.log(`synching ... ${msgToBeSynched.header.messageID}`)
+        target_payload_subject.next(msgToBeSynched)
+    }
 })
+