I did not find a solution to this. And ended up redesigning the solution, so that I don't need to set a variable from the extension.
IF someone knows the answer on how to do this, I would still like to know how. Because I can see the potential need for setting a variable from an extension arise again. Without necessarily having to trigger a reload of the extension.