Remove singletons from the core
Background / User story
This is part of the work #421 (closed), and also will help tremendously for #373 (moved).
We have a lot of the core internal that are setup as a singleton object that is obtained through a require. This mean we have a global state that leaks everywhere.
However the webext-sdk only uses filterStorage
, filterEngine
, defaultMatcher
and synchronnizer
, sometime just to start them.
We want to get rid of these singleton and eventually either have a few independent instance that the client (webext-sdk) would create, or a single object for the core.
What to change
Development:
- Remove the singletons and fix the tests.
Documentation:
- API changes will need to be.
Hints for testing
- Test should all pass.
- Further testing will be needed
Integration notes
See https://gitlab.com/eyeo/adblockplus/abc/webext-sdk/-/merge_requests/321 and https://gitlab.com/eyeo/adblockplus/abc/webext-sdk/-/merge_requests/353 for an example
-
defaultMatcher
is no longer exported frommatcher
and should be accessed asfilterEngine.defaultMatcher
-
elemHideEmulation
,elemHide
andsnippets
are accessed as a property offilterEngine
-
filterStorage
is accessed as a property offilterEngine
, and is intanciated by the engine. -
filterState
is accessed as a property offilterStorage
-
synchronizer
is accessed as a property offilterStorage
-
filterEngine
must be instantiated: the class is the symbol imported (FilterEngine
)
Edited by Hubert Figuière