-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement simple event emitter for FiltersEngine and sub-classes #251
Conversation
27be7e1
to
30d727d
Compare
Could there be a chance that these event names will conflict with the event names used in the user application or from another library? |
This should not happen as the events are "local" to the blocker instance. For example you can have two instances emitting the same events and register two different callbacks to each: const blocker1 = ElectronBlocker.parse('||domain1.com');
const blocker2 = ElectronBlocker.parse('||domain2.com');
blocker1.on('request-blocked', () => { console.log('blocker1!'); });
blocker2.on('request-blocked', () => { console.log('blocker2!'); }); Did I understand your question correctly? |
Sorry since I didn't see any example code I thought the events was implemented via electron's ipcMain/ipcRenderer (since I was using adblocker-electron). If the events is local to the adblocker then of course there should be no problem. |
Indeed! I tried to implement this mechanism in such a way that all blockers can benefit from it: WebExtension, Electron, Puppeteer, etc. You can see a small example here: https://github.com/cliqz-oss/adblocker/blob/30d727d240ceca0e52f0c2089d8290bef8a1eff4/packages/adblocker-electron-example/index.ts#L70 |
* request-blocked * request-redirected * request-whitelisted * csp-injected * script-injected * style-injected
30d727d
to
8c63861
Compare
@remusao when it's planned to be a new release for this? thx. |
@btzsoft I was planning on releasing this with a few other changes that are in the pipeline but not related. But actually there is no strong reason to not release what is already on |
@remusao this would be great. Thank you! |
@btzsoft done. Let me know if you encounter any issue. |
@remusao I have an warning, is this ok?
|
the adblocker throws when try to parse |
@btzsoft weird, this error should only happen if the installed version of |
@remusao yes was |
Following events are implemented:
Fixes #80
Fixes #247