nsIObserverService
From MDC
Contents |
[edit] Summary
The nsIObserverService interface provides methods to add, remove, notify, and enumerate observers of various notifications.
nsIObserverService is defined in xpcom/ds/nsIObserverService.idl. It is scriptable and
has been frozen since Mozilla 0.9.6. See bug 99163 for details.
#include "nsIObserverService.h"
[scriptable, uuid=(D07F5192-E3D1-11d2-8ACD-00105A1B8860)]
interface nsIObserverService : nsISupports { ... };
The XPCOM nsObserverService implements this interface to provide global notifications for a variety of subsystems.
[edit] Method overview
void addObserver(in
|
void removeObserver( in
|
void notifyObservers( in
|
|
[edit] Methods
[edit] addObserver()
Registers a given listener for a notifications regarding the specified topic.
void addObserver( in nsIObserver anObserver,
in string aTopic,
in boolean ownsWeak);
[edit] Parameters
- anObserver
- The interface pointer which will receive notifications.
- aTopic
- The notification topic or subject.
- ownsWeak
- If set to
false, thensIObserverServicewill hold a strong reference toanObserver. If set totrueandanObserversupports thensIWeakReferenceinterface, a weak reference will be held. Otherwise an error will be returned.
[edit] removeObserver()
Unregisters a given listener from notifications regarding the specified topic.
void removeObserver( in nsIObserver anObserver,
in string aTopic );
[edit] Parameters
- anObserver
- The interface pointer which will stop receiving notifications.
- aTopic
- The notification topic or subject.
[edit] notifyObservers()
Notifies all registered listeners of the given topic.
void notifyObservers( in nsISupports aSubject,
in string aTopic,
in wstring someData );
[edit] Parameters
- aSubject
- Notification specific interface pointer.
- aTopic
- The notification topic or subject.
- someData
- Notification specific wide string.
[edit] enumerateObservers()
Returns an enumeration of all registered listeners.
nsISimpleEnumerator enumerateObservers( in string aTopic );
[edit] Parameters
- aTopic
- The notification topic or subject.
[edit] Return value
Returns an enumeration of all registered listeners.
[edit] See Also
- nsObserverService
- Observer Notifications provides an overview of observers and a list of built-in notifications fired by Mozilla.