Synchronous function calls - possible? Best practises?

Hello everyone,

I am new to developing Firefox addons and already on a rather dead end, so please bear with me. My main problem is that, from the main.js, I want to make function calls to a given tab and also receive an answer within the same function. So in my addon, it would look something like:

function getHTML(tab) {
    // access the tab and get the response
    return html;
}

However, with the whole port.on(“bla”, …) stuff and page mods bein attached and re-attached, I have no idea if there is a convenient way of doing this. I’m not even sure what to search for =/

Any help is greatly appreciated :smile:

Best practice: Dont do it

:stuck_out_tongue:

I only do it while testing addons.
With addon sdk they havent created apis for but you can tap into your addon scope.

Thx for the hint, will look into it asap^^ I am also currently looking into mozrepl, since I want to control my addon from the outside and maybe that is the way to go :open_mouth:

It definitely is the way to go, here is a gist i regularly use to access my scope:

Now that acesses the bootstrap.js scope, with sdk addons you have main.js so from your bootstrap.js you have to get to main.js i have never done it so i cant share but when you figure it out please do share.