Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#3862 closed change (fixed)

Implement FilterNotifier.on(action, callback) and FilterNotifier.off(action, callback)

Reported by: sebastian Assignee: sebastian
Priority: Unknown Milestone:
Module: Core Keywords:
Cc: trev, kzar Blocked By:
Blocking: #3868 Platform: Unknown / Cross platform
Ready: no Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29338969
https://codereview.adblockplus.org/29339038
https://codereview.adblockplus.org/29338973
https://codereview.adblockplus.org/29338976

Description

Background

Currently, there is only FilterNotifier.addListener() which adds a single-dispatch listener which is called for ever single filter event. That is inconvenient when you are only interested in particular events, inconsistent with newer APIs we recently added (#3499 and #3826), and inefficient.

What to change

Add folowing methods to the FilterStorage object:

  • FilterStorage.on(action, listener)
    • Adds a listener function that is only called for the specified filter action.
  • FilterStorage.off(action, listener)
    • Removes a listener function for the specified filter action.
  • FilterStorage.emit(action[, arg1[, arg2[, ...]]])
    • Calls all listeners for the specified filter action with the given arguments.

Adapt lib/filterListener.js and lib/antiadblockInit.js to use the new API, and mark the old API (i.e. addListener, removeListener and triggerFilters) as deprecated but make sure that they still work as before for backwards compatibility.

Change History (7)

comment:1 Changed 4 years ago by sebastian

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed 4 years ago by abpbot

A commit referencing this issue has landed:
https://hg.adblockplus.org/adblockpluscore/rev/047d73bc52f3

comment:3 Changed 4 years ago by sebastian

  • Review URL(s) modified (diff)

comment:4 Changed 4 years ago by sebastian

  • Blocking 3868 added

comment:6 Changed 4 years ago by sebastian

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:7 Changed 4 years ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Subscriptions are working as expected with no obvious regressions. State stays consistent between the preferences window and the first-run page.

ABP 2.7.2.4166
Firefox 38 / 44 / Windows 8
Nightly 48.0a1 (2016-04-19) / Windows 8
Firefox 38 / 44 / OS X 10.11
Firefox 45.01 / Ubuntu 14.04
Nightly 48.0a1 (2016-04-19) / Ubuntu 14.04

Note: See TracTickets for help on using tickets.