Replace filterNotifier.emit() with a package-level alternative
Background
The APIs in eyeo/adblockplus/adblockpluscore> are marked either public or package-level. There is one object that still exposes a public API that should be marked package-level: filterNotifier
. The filterNotifier.emit()
function is (wrongly) being called directly from eyeo/adblockplus/adblockpluschrome>. In fact, eyeo/adblockplus/adblockpluschrome> should use its own EventEmitter
object for its own events. We should close this loophole so we can have more of a guarantee of an internally consistent state. This should make it easier to make internal changes to eyeo/adblockplus/adblockpluscore> in the future.
eyeo/adblockplus/adblockpluschrome!261 (closed) should already fix this at the eyeo/adblockplus/adblockpluschrome> end.
What to change
Make a new class FilterNotifier
that acts as a façade over an EventEmitter
object. It should have public on()
and off()
methods that invoke the equivalent methods on the internal EventEmitter
object. Additionally, it should have a package-level dispatch()
method that forwards the call to EventEmitter#emit()
.
filterNotifier
from lib/filterNofifier.js
should be an instance of the new FilterNotifier
class.
The following files need to be updated to call filterNotifier.dispatch()
instead of filterNotifier.emit()
:
lib/elemHide.js
lib/elemHideExceptions.js
lib/filterListener.js
lib/filterState.js
lib/filterStorage.js
lib/subscriptionClasses.js
lib/synchronizer.js
test/filterNotifier.js
Integration notes
filterNotifier.emit()
is no longer available. Use a separate EventEmitter
instance (see lib/events.js
) for custom events. The purpose of filterNotifier
is to emit events from within eyeo/adblockplus/adblockpluscore> itself.