The thing is that I have an "a()" function in an external .js that I can't edit and I need to execute a function of mine after that one is executed. I found this on the internet
$.when(function1()).then(function2());
The thing with this is that it's jQuery and I don't use jQuery. I need to do it with pure javascript. Someone know how to I can do?
EDIT: They asked for my code, I don't know why it's important but here it is.
function a(){
alert("Hola función a");
return false;
}
function mifuncion(){
alert("Hola función mifunción");
}
NOTE : I don't have access to function a() so I can't edit anything. I do have access to myFunction function.
If you just want to be able to execute something after you call
a
, you could wrapa
it and add an optional callback to it:If what you want is to find out that from anywhere someone calls
a
, in a very similar way you could:If I have understood you correctly, you could achieve it by using a
Promise
and passing theresolve
de laPromise
so that the function b is executed in athen
, something like this:Hope it works for you. Greetings.
If I didn't misunderstand the problem, I think the easiest thing to do is to call and manage the a() function inside your myfunction() function.