In order to keep a clean, easy and maintainable code, I want to exit a function, after the user has closed a MessageBox.... BUT the anonymous function is triggered async, therefore not blocking. Is there a best practice to achieve this? I always was in love with c#'s MessageBox implementation.... so I expected this in UI5, too. So sad. Here the code...
} else { } */
MsgBox.error(info,
{
actions: [MsgBox.Action.OK], emphasizedAction: MsgBox.Action.NO,
onClose: function (sAction)
{
abort = true;
}
});
}
if(abort){
return;
}
this.clearLocalModel();
// code
// more code
// which is executed , but should not
// I KNOW, i can redesign this with if else... and so on- BUT
// i would like to keep it pretty simple...
UPDATE:
I tried the idea with the promise, returning a bool. As "promised" I returned for feedback, and I am in the same situation like before... in this case I added screenshots, I hope, You don't mind...
Caller:
Callee:


On a very high level you could create something like the following function. It presents a
MessageBoxand depending on what the user clicks resolves or rejects a promise.Then from somewhere else you can call this function and wait for the result (using
thenorasync/awaitwhich both will feel more like a synchronous flow).