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

Unified Diff: lib/filterClasses.js

Issue 29935568: Issue 7096 - Make it possible to lazy initialize a filter's subscriptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Small update Created Nov. 3, 2018, 9:34 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 | lib/filterListener.js » ('j') | lib/filterStorage.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
===================================================================
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -55,23 +55,16 @@
* Abstract base class for filters
*
* @param {string} text string representation of the filter
* @constructor
*/
function Filter(text)
{
this.text = text;
-
- /**
- * Subscriptions to which this filter belongs.
- * @type {(Subscription|Set.<Subscription>)?}
- * @private
- */
- this._subscriptions = null;
}
exports.Filter = Filter;
Filter.prototype =
{
/**
* String representation of the filter
* @type {string}
@@ -83,16 +76,40 @@
* @type {string}
*/
get type()
{
throw new Error("Please define filter type in the subclass");
},
/**
+ * Subscriptions to which this filter belongs.
+ * @type {(Subscription|Set.<Subscription>)?}
+ * @private
+ */
+ _subscriptions: null,
+
+ /**
+ * Whether the filter's subscriptions have already been added to the filter.
+ * @type {boolean}
+ * @package
+ */
+ get subscriptionsAdded()
+ {
+ return this.hasOwnProperty("_subscriptions");
+ },
+ set subscriptionsAdded(value)
+ {
+ // Once set to true, the cannot be set back to false even if all
hub 2018/11/10 04:33:21 typo.
+ // subscriptions are removed.
+ if (value)
+ this._subscriptions = this._subscriptions;
hub 2018/11/10 04:33:21 I don't understand what's happening here. This ass
Manish Jethani 2018/11/15 22:58:52 Not really, it sets the property on the this objec
hub 2018/11/16 17:04:39 Acknowledged.
+ },
+
+ /**
* Yields subscriptions to which the filter belongs.
* @yields {Subscription}
*/
*subscriptions()
{
if (this._subscriptions)
{
if (this._subscriptions instanceof Set)
« no previous file with comments | « no previous file | lib/filterListener.js » ('j') | lib/filterStorage.js » ('J')

Powered by Google App Engine
This is Rietveld