|
@@ -11,26 +11,13 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
|
|
private sourceSrc: LoggingService = new LoggingService()
|
|
private sourceSrc: LoggingService = new LoggingService()
|
|
private targetSrc: LoggingService = new LoggingService()
|
|
private targetSrc: LoggingService = new LoggingService()
|
|
|
|
|
|
- public async init(settings: MessageSynchronisationServiceSetting): Promise<void> {
|
|
|
|
|
|
+ public init(settings: MessageSynchronisationServiceSetting): void {
|
|
this.settings = settings;
|
|
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
|
|
// Incoming obstriger serves as a trigger point to perform another synchronization
|
|
public subscribe(obsTrigger: Observable<string>): Observable<BaseMessage> {
|
|
public subscribe(obsTrigger: Observable<string>): Observable<BaseMessage> {
|
|
- let msg : Subject<BaseMessage> = new Subject()
|
|
|
|
|
|
+ let msg: Subject<BaseMessage> = new Subject()
|
|
obsTrigger.subscribe({
|
|
obsTrigger.subscribe({
|
|
next: obs => {
|
|
next: obs => {
|
|
let missingMsg = this.dataConversion()
|
|
let missingMsg = this.dataConversion()
|
|
@@ -42,7 +29,7 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
|
|
}
|
|
}
|
|
})
|
|
})
|
|
// trigger by timer
|
|
// trigger by timer
|
|
- if(!obsTrigger) {
|
|
|
|
|
|
+ if (!obsTrigger) {
|
|
this.dataConversion()
|
|
this.dataConversion()
|
|
}
|
|
}
|
|
let result: Observable<BaseMessage> = msg.asObservable()
|
|
let result: Observable<BaseMessage> = msg.asObservable()
|