Closed
Bug 308807
Opened 19 years ago
Closed 19 years ago
[RFE] Need standard way to add and remove event listeners to XPCOM objects
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
DUPLICATE
of bug 308798
People
(Reporter: bastiaan, Assigned: dougt)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 The way XPCOM exposes events and allows listeners to consume these events is different for almost every XPCOM object. There needs to be a coding convention on how to make XPCOM objects that expose events and allow listeners/handlers to be added and removed. For instance, nsIMsgSend notifies a nsIMsgSendListener onStartSending and onStopSending, etc., but there is no good way to add a nsIMsgSendListener to a nsIMsgSend instance. The only way is to pass it as a parameter to the nsIMsgSend.createAndSendMessage and sendMessageFile methods. Other objects expose the listener as a property of the object. For instance, nsIMsgCompose has a recyclingListener property. Sometimes the listener can be added to or removed from an object with addListener and removeListener, as is the case with nsISoapTransport. This is the way I would prefer event listener to be added and removed. I understand that refactoring all existing code is almost impossible as it would break a lot of existing products and extensions, but it might be possible to add the 'new-and-improved' way and leaving the old code intact (deprecating it for future use). This would be very useful to have, and would easify making extensions that want to act upon XPCOM 'events'. Reproducible: Always Steps to Reproduce:
*** This bug has been marked as a duplicate of 308798 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•