| Index: lib/messaging.js | 
| =================================================================== | 
| --- a/lib/messaging.js | 
| +++ b/lib/messaging.js | 
| @@ -37,29 +37,26 @@ | 
| _onMessage: function(message, sender, sendResponse) | 
| { | 
| let async = false; | 
| - let callbacks = this._eventEmitter._listeners[message.type]; | 
| + let callbacks = this._eventEmitter.listeners(message.type); | 
| - if (callbacks) | 
| + for (let callback of callbacks) | 
| { | 
| - for (let callback of callbacks) | 
| + let response = callback(message, sender); | 
| + | 
| + if (response && typeof response.then == "function") | 
| { | 
| - let response = callback(message, sender); | 
| - | 
| - if (response && typeof response.then == "function") | 
| - { | 
| - response.then( | 
| - sendResponse, | 
| - reason => { | 
| - console.error(reason); | 
| - sendResponse(undefined); | 
| - } | 
| - ); | 
| - async = true; | 
| - } | 
| - else if (typeof response != "undefined") | 
| - { | 
| - sendResponse(response); | 
| - } | 
| + response.then( | 
| + sendResponse, | 
| + reason => { | 
| + console.error(reason); | 
| + sendResponse(undefined); | 
| + } | 
| + ); | 
| + async = true; | 
| + } | 
| + else if (typeof response != "undefined") | 
| + { | 
| + sendResponse(response); | 
| } | 
| } |