У меня есть метод, который запускает два разных события. Второе событие не запускается. Однако, когда я закомментирую, что первое событие отлучено, второе срабатывает, как и ожидалось.
Если я уменьшу код до этого:
public async approve() {
this.isLoadingChange.emit(true);
this.actionPerformed.emit();
}
оба события работают нормально.
Вот метод, который я вызываю для дочернего компонента:
public async approve() {
try {
this.isLoadingChange.emit(true);
await this._letterService.approveLetter(this.letter.letterQueueId);
this._toastrService.success('Successfully approved letter.', 'Success');
} catch(ex) {
this._toastrService.error('Something went wrong. Could not approve letter.', 'Error');
console.error(ex);
} finally {
console.log("finally?");
this.actionPerformed.emit();
}
}
А вот мои события на родителях:
public async onActionPerformed($event) {
console.log("action performed", this.isLoading);
if($event) {
this.request.templateIds = [$event.templateId];
this.request.hashValue = $event.hashValue;
this.filterPatternTemplate = `TemplateId: ` + this.request.templateIds[0];
this.filterPatternHash = `Hash: ` + this.request.hashValue;
}
await this.performSearch();
console.log("search complete", this.isLoading);
}
public async onIsLoadingChange(newValue: boolean) {
console.log(newValue);
this.isLoading = newValue;
}