Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/messaging.js

Issue 29339020: Issue 3868 - Use the new FilterNotifier API (Closed)
Patch Set: Updated depdendencies and use EventEmitter.listeners() Created March 24, 2016, 3:29 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/icon.js ('k') | lib/requestBlocker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « lib/icon.js ('k') | lib/requestBlocker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld