Listen for events in the xkit.js library

Parameters

  1. event: 'config:update' | 'connection:enable' | 'connection:remove' | 'connection:disable'
    The type of event to subscribe to messages for
  2. fn: (payload: unknown) => void
    A function to be called when the event is triggered, with a payload specific to the event.

Returns

void

xkit.on('connection:enable', () => console.log('connection enabled!'))

xkit.js allows consumers to subscribe to certain events in the library. This can be particularly useful if you are using xkit.js via xkit-catalog.js where you do not control the full lifecycle of connections.

Events available:

Event NamePayloadDescription
config:updatexkit.js keeps the user's logged in state. When that state changes (e.g. when a user is logged in or out), this event will fire.
connection:enableConnectionWhen a user connects or reconnects, this event will be fired with the updated connection object.
connection:removeConnectionWhen a user removes a connection, this event will be fired with the connection object before it was removed.
connection:disable
DEPRECATED
stringWhen a user removes a connection, this event will be fired with the slug of the Connector that was removed. DEPRECATED: prefer connection:remove