Drop chrome.runtime.onMessage events

We can use Backbone.Events instead.

// FREEBIE
This commit is contained in:
lilia 2017-02-27 14:41:51 -08:00
parent bba25b22e2
commit 886557a2aa
3 changed files with 5 additions and 20 deletions

View file

@ -27,23 +27,6 @@
return self;
}());
window.extension.trigger = function (name, object) {
chrome.runtime.sendMessage(null, { name: name, data: object });
};
window.extension.on = function (name, callback) {
// this causes every listener to fire on every message.
// if we eventually end up with lots of listeners (lol)
// might be worth making a map of 'name' -> [callbacks, ...]
// so we can fire a single listener that calls only the necessary
// calllbacks for that message name
chrome.runtime.onMessage.addListener(function(e) {
if (e.name === name) {
callback(e.data);
}
});
};
extension.windows = {
open: function(options, callback) {
if (chrome.windows) {