I'm using Daniel Buchner's Sidebar library.
- https://builder.addons.mozilla.org/package/25177/latest/
Is it possible for the addon to communicate with the sidebar.
/*** main.js ***/
var sidebarPanel = require('sidebar')sidebar({
header: false,
width:'200px',
url: data.url('panel.html'),
onDomReady: function(){
this.injectAssets({
css: [data.url('panel.css')],
js: [data.url('panel.js')]
});
}
});
sidebarPanel.port.on('msg', function(sidebarmessage){
console.log(sidebarmessage);
});
sidebarPanel.port.emit('msg', 'hello sidebar');
/*** panel.js ***/
self.port.on('msg', function(addonmessage){
console.log(addonmessage);
});
self.port.emit('msg', 'hello addon');
I have read the "using port" docs but cannot figure out a solution. https://addons.mozilla.org/en-US/developers/docs/sdk/1.12/dev-guide/guides/content-scripts/using-port.html
I tried to modify the page-mod example for using port but was unsuccessful. Any help here would be appreciated.
The sidebar module you linked to is not an official SDK api and ( now that I look at the code ) does not feature the typical SDK pattern of being able to comunicate via async message-passing. In it's current state, it just isn't capable of doing that.