Hi João,
This is a great question!
When I had this type of scenario in my traditional web apps mainly in OutSystems 10 when we didn't had events,I usually used more than one hided button or links.
For example,
If I had to first call a server action that was going to return some sort of input for the next action, first I called it then in the end I called another runJavascript to do whatever I needed, even using RunJS to click in other button if needed.
Another thing that came in my mind is that you may use some default OutSystems objects for this, for example, if you go to your console and type OS you will see a lot of OS objects:

One of them is the osajaxbackend, that has several funciton including BindAfterAjaxRefresh which let you set some function that will run every time you do an ajax refresh:

This action if used will run every time, so you would have to find a way to identify if the caller was the button or link you wanted for instance.
This is just some sort of Brain Storm, I never used this type of approach.... But it may also help you to think in some other thing.
The last thing I think is using callbacks on the JS functions to start another function maybe...
Just ideias :)