I need to check if a thing exists before anything else happens. I listen for input via the eventBus like so:
eventBus.on('element.updateId', (event) => {
const b = async ()=> {
return await this.checkNewId(event.newId).then()
}
return b();
});
and this is the service function that needs to complete, but it doesn't complete instead it moves on to other functions - what am i doing wrong?
checkNewId(newId) {
return this.myService.getDiagram(newId).pipe(
tap(
(data) => {
this.validationErrors.next('Duplicate');
return data;
},
(err) => {
this.validationErrors.next('');
}
),
first()
).toPromise();
}
I tried to follow this example here: Subscription to promise