Listeners in Experimental apis

I have a listener in an experimental api

  var myAlertForClosure = function(event) {myAlertToSend(event);}
  mySendButton.addEventListener("click",myAlertForClosure,true);

The trouble is that I need to put the function myAlertToSend in my background script. I’ve read the documents but I’m not understanding… Can you give me a heads up how to do this?

Even when I started out with it defined in the api, I got an error - saying that it wasn’t defined even if the addon would then run the code I had to that point…
Blessings

Sounds like you want to send message to your background script to execute that function. Something like: browser.runtime.sendMessage({type: 'executeXYZ', parameters: ['a', 'b', 'c']}).
See this related topic: