I'm creating a Chrome extension.
I have the following function that I want to return True or False depending on the message answered. OK true, otherwise false. The function that must return true / false is sendMsgToBackgroundChangeStatus ()
function sendMsgToBackgroundChangeStatus(){
chrome.runtime.sendMessage({'since':'popup', 'activo': !activo}, function(response){
//alert("Popup: " + response.status);
//console.log("Popup: " + response.status);
return response.status;
}
);
}
if (SendMsgToBackgroundChangeStatus()){
//block code
} else {
//block code
}
There are several problems. The first problem is the execution of the code asynchronously. The second I do not know how I can get the result of a function inside another function.
The idea is that according to the answer from endMsgToBackgroundChangeStatus () (True or False) the conditional block code is executed (if (SendMsgToBackgroundChangeStatus ()))
Any ideas?
Thanks in advance.
Greetings.