@digitalpersona/devices
Version:
DigitalPersona Security Devices support library
51 lines (33 loc) • 1.54 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[](./index.md) > [@digitalpersona/devices](./devices.md) > [WindowsAuthClient](./devices.windowsauthclient.md) > [on](./devices.windowsauthclient.on.md)
Adds an event handler for the event. This is a multicast subscription, i.e. many handlers can be registered at once.
<b>Signature:</b>
```typescript
on<E extends Event>(event: string, handler: Handler<E>): Handler<E>;
```
| Parameter | Type | Description |
| --- | --- | --- |
| event | <code>string</code> | a name of the event to subscribe, e.g. "CommunicationFailed" |
| handler | <code>Handler<E></code> | an event handler. |
<b>Returns:</b>
`Handler<E>`
an event handler reference. Store the reference and pass it to the [WindowsAuthClient.off()](./devices.windowsauthclient.off.md) to unsubscribe from the event.
```
class IntegratedWindowsAuthComponent
{
private client: WindowsAuthClient;
private onCommunicationFailed = (event: CommunicationFailed) => { ... }
public $onInit() {
this.client = new WindowsAuthClient();
this.client.on("CommunicationFailed", this.onCommunicationFailed);
}
public $onDestroy() {
this.client.off("CommunicationFailed", this.onCommunicationFailed);
// alternatively, call this.reader.off() to unsubscribe from all events at once.
delete this.client;
}
}
```