This repository has been archived by the owner on Oct 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
sp core library.spevent.add
John Nguyen edited this page Apr 22, 2021
·
2 revisions
Home > @microsoft/sp-core-library > SPEvent > add
Registers a callback that will be invoked whenever the event occurs.
Signature:
add(observer: ISPEventObserver, eventHandler: (eventArgs: TEventArgs) => void): void;
Parameter | Type | Description |
---|---|---|
observer | ISPEventObserver | Indicates the object that is subscribing to the event: When the object is disposed, the event handler will be automatically removed. This object is also used for diagnostic purposes, e.g. detecting if the event handler failed to catch an exception. |
eventHandler | (eventArgs: TEventArgs) => void | A callback function that will be invoked whenever the event occurs |
Returns:
void
The same object can add multiple event handlers to the same event. Since BaseComponent implements the ISPEventObserver interface, a web part or extension can pass itself as the observer. This will cause the event handler to be automatically unsubscribed when the web part or extension is disposed.