Closed
Bug 308798
Opened 19 years ago
Closed 12 years ago
[RFE] Need standard way to add and remove event listeners to XPCOM objects
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: bastiaan, Unassigned)
References
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:
Comment 1•19 years ago
|
||
Yes, I agree with you. Currently it is almost impossible to know what is going on in XPCOM objects. Searching the documentation and code for ways to get notified on certain events is really hard and frustrating, especially when you finally discover that it is impossible to do what you're trying to do. I think it is necessary to define what an event really is and how handlers should be managed and notified. I think we are talking about different types of events than nsIEventQueue stuff?
*** Bug 308807 has been marked as a duplicate of this bug. ***
Comment 4•17 years ago
|
||
Might be interesting to our excellent evangelism team. Ccing mfinkle and jresig.
Updated•12 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•