Class

Listener

Listener()

A class to bind event listener for custom events.
Constructor

# new Listener()

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

Methods

# onAuthFlowCompleted(callback, onceopt) → {CleanupFunc}

Adds an event listener for hanko-auth-flow-completed events. Will be triggered after the login or registration flow has been completed.
Parameters:
Name Type Attributes Description
callback CallbackFunc.<AuthFlowCompletedDetail> 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 280

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

# 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 237

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 249

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 270

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 260

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 138

# 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 155

string

# authFlowCompletedType

The type of the `hanko-auth-flow-completed` event.

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

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

# userDeletedType

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

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

string

# userLoggedOutType

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

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