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

Unified Diff: background.js

Issue 29338734: Issue 3839 - Adapt for Prefs event changes (Closed)
Patch Set: app.listen doesn't need a FilterNotifier listener Created March 21, 2016, 5:18 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 | « no previous file | messageResponder.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -93,7 +93,15 @@
modules.prefs = {
Prefs: {
- onChanged: new Notifier()
+ _listeners: Object.create(null),
+
+ on: function(preference, callback)
+ {
+ if (preference in this._listeners)
+ this._listeners[preference].push(callback);
+ else
+ this._listeners[preference] = [callback];
+ }
}
};
var prefs = {
@@ -114,8 +122,11 @@
set: function(value)
{
prefs[key] = value;
- modules.prefs.Prefs.onChanged.triggerListeners(key);
- return prefs[key];
+
+ var listeners = modules.prefs.Prefs._listeners[key];
+ if (listeners)
+ for (var i = 0; i < listeners.length; i++)
+ listeners[i]();
}
});
});
« no previous file with comments | « no previous file | messageResponder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld