I have a method written on onclick event on LWC Js for a datatable.
handleOnclickSelect(event) {
let accountRec = event.detail.row;
let targetRowId = accountRec.Id;
this.checkAccountDetails(targetRowId);
console.log('Called On Click Method');
console.log('Result Value ',this.hasresult);
}
checkAccountDetails(recordId) {
checkAccountDtsRec({
accountId: recordId
})
.then(result => {
if (result != undefined) {
// some logic
this.hasresult = true;
console.log('Logic Inside Method');
}
}
while this code is getting executed. I found the console log in the following order -
- Called On Click Method
- Result Value undefined
- Logic Inside Method
Is the cursor not moved to the calling method and once completed then come back to the main method from where it was called ? Is this expected in a promise callback ?