OfficeExtension.EventHandlers class

Constructors

(constructor)(context, parentObject, name, eventInfo)

Constructs a new instance of the EventHandlers class

Methods

add(handler)

Adds a function to be called when the event is triggered.

remove(handler)

Removes the specified function from the event handler list so that it will not be called on subsequent events.

Note: The same RequestContext object that the handler was added in must be used when removing the handler. More information can be found in Remove an event handler.

Constructor Details

(constructor)(context, parentObject, name, eventInfo)

Constructs a new instance of the EventHandlers class

constructor(context: ClientRequestContext, parentObject: ClientObject, name: string, eventInfo: EventInfo<T>);

Parameters

name

string

Method Details

add(handler)

Adds a function to be called when the event is triggered.

add(handler: (args: T) => Promise<any>): EventHandlerResult<T>;

Parameters

handler

(args: T) => Promise<any>

A promise-based function that takes in any relevant event arguments.

Returns

remove(handler)

Removes the specified function from the event handler list so that it will not be called on subsequent events.

Note: The same RequestContext object that the handler was added in must be used when removing the handler. More information can be found in Remove an event handler.

remove(handler: (args: T) => Promise<any>): void;

Parameters

handler

(args: T) => Promise<any>

A reference to a function previously provided to the add method as an event handler.

Returns

void