Class

Listener

Listener()

A class to bind event listener for custom events.
Constructor

# new Listener()

View Source lib/events/Listener.ts, line 10

Methods

# onSessionCreated(callback, onceopt) → {CleanupFunc}

Adds an event listener for "hanko-session-created" events. Will be triggered across all browser windows, when the user logs in, or when the page has been loaded or refreshed and there is a valid session.
Parameters:
Name Type Attributes Description
callback CallbackFunc.<SessionDetail> The function to be called when the event is triggered.
once boolean <optional>
Whether the event listener should be removed after being called once.

View Source lib/events/Listener.ts, line 227

This function can be called to remove the event listener.
CleanupFunc

# onSessionExpired(callback, onceopt) → {CleanupFunc}

Adds an event listener for "hanko-session-expired" events. The event will be triggered across all browser windows as soon as the current JWT expires or the user logs out. It also triggers, when the user deletes the account in another window.
Parameters:
Name Type Attributes Description
callback CallbackFunc.<null> The function to be called when the event is triggered.
once boolean <optional>
Whether the event listener should be removed after being called once.

View Source lib/events/Listener.ts, line 239

This function can be called to remove the event listener.
CleanupFunc

# onUserDeleted(callback, onceopt) → {CleanupFunc}

Adds an event listener for hanko-user-deleted events. The event triggers, when the user has deleted the account.
Parameters:
Name Type Attributes Description
callback CallbackFunc.<null> The function to be called when the event is triggered.
once boolean <optional>
Whether the event listener should be removed after being called once.

View Source lib/events/Listener.ts, line 260

This function can be called to remove the event listener.
CleanupFunc

# onUserLoggedOut(callback, onceopt) → {CleanupFunc}

Adds an event listener for hanko-user-deleted events. The event triggers, when the user has deleted the account in the browser window where the deletion happened.
Parameters:
Name Type Attributes Description
callback CallbackFunc.<null> The function to be called when the event is triggered.
once boolean <optional>
Whether the event listener should be removed after being called once.

View Source lib/events/Listener.ts, line 250

This function can be called to remove the event listener.
CleanupFunc

Type Definitions

# CallbackFunc(detail)

A callback function to be executed when an event is triggered.
Parameters:
Name Type Description
detail T

View Source lib/events/Listener.ts, line 128

# CleanupFunc()

A function returned when adding an event listener. The function can be called to remove the corresponding event listener.

View Source lib/events/Listener.ts, line 145

string

# sessionCreatedType

The type of the `hanko-session-created` event.

View Source lib/events/CustomEvents.ts, line 2

string

# sessionExpiredType

The type of the `hanko-session-expired` event.

View Source lib/events/CustomEvents.ts, line 8

string

# userCreatedType

The type of the `hanko-user-created` event.

View Source lib/events/CustomEvents.ts, line 32

string

# userDeletedType

The type of the `hanko-user-deleted` event.

View Source lib/events/CustomEvents.ts, line 20

string

# userLoggedInType

The type of the `hanko-user-logged-in` event.

View Source lib/events/CustomEvents.ts, line 26

string

# userLoggedOutType

The type of the `hanko-user-logged-out` event.

View Source lib/events/CustomEvents.ts, line 14