Events

The Kuzzle object exposes a set of events triggered on some cases. To subscribe or unsubscribe on these events, simply plug a callback function to the event you want to listen, using the functions addListener and removeListener.


Exposed events

Event NameCallback argumentsDescription
connected(none)Triggered when the SDK has successfully connected to Kuzzle
discardederror (object)Triggered when Kuzzle rejects a request (e.g. request can't be parsed, request too large, ...)
disconnected(none)Triggered when the current session has been unexpectedly disconnected
loginAttempt{ "success": <boolean>, "error": "<error message>" }Triggered when a login attempt completes, either with a success or a failure result
networkErrorerror (object)Triggered when the SDK has failed to connect to Kuzzle. Does not trigger offline mode.
offlineQueuePopquery (object)Triggered whenever a request is removed from the offline queue.
offlineQueuePush{ "query": <object>, "cb": <function> }Triggered whenever a request is added to the offline queue
queryErrorerror (object), query (object)Triggered whenever Kuzzle responds with an error
reconnected(none)Triggered when the current session has reconnected to Kuzzle after a disconnection, and only if autoReconnect is set to true
tokenExpired(none)Triggered when Kuzzle rejected a request because the authentication token expired

Note: listeners are called in the order of their insertion.