The idea of this is to allow the deletion of events with a priority.
What right now happens:
- We get a deletion call with obj, cb, data. We linear walk down the list of callbacks, and delete the first finding of a subscription that meets obj, cb, data parameters.
Problem with that:
A user could add a callback twice with the same data with 2 different priorities, now only the first priority will be deleted, (note: the list is sorted by the priority)
What we could do:
Add a priority to those calls:
We start to walk the list of subscriptions like before, but we don't do anything until we are at a subscription where the priority is >= to the one supplied, then we safe this spot, continue to search for a matching subscription, when we are at the end, we are rolling over to index 0, continuing to the spot that we have safed.
For API usages where we don't have a priority, we can just insert the smallest priority, which will end up in the same behaviour as before. However, we provide the user with a API for the usecase he uses 2 different priorities.