SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

Read-only properties #

Property name Type Description
authenticated
boolean
Returns true if the SDK holds a valid token
connected
boolean
Returns true if the SDK is currently connected to a Kuzzle server.
offlineQueue
object[]
Contains the queued requests during offline mode
protocol
Protocol
Protocol used by the SDK

connected #

The connected property wraps the underlying protocol connected property. See the associated documentation:

Writable properties #

Property name Type Description
autoQueue
boolean
If true, automatically queues all requests during offline mode
autoReplay
boolean
If true, automatically replays queued requests on a reconnected event
autoResubscribe
boolean
If true, automatically renews all subscriptions on a reconnected event
jwt
string
Authentication token
offlineQueueLoader
function
Called before dequeuing requests after exiting offline mode, to add items at the beginning of the offline queue
queueFilter
function
Custom function called during offline mode to filter queued requests on-the-fly
queueMaxSize
number
Number of maximum requests kept during offline mode
queueTTL
number
Time a queued request is kept during offline mode, in milliseconds
replayInterval
number
Delay between each replayed requests
volatile
object
Common volatile data, will be sent to all future requests

offlineQueueLoader #

The offlineQueueLoader property must be set with a function of one of the following formats:

Copied to clipboard!
Object[] offlineQueueLoader()

Promise<Object[]> offlineQueueLoader()

The returned (or resolved) array must contain objects, each with the following properties:

Property Type Description
query
object
Object representing the request that is about to be sent to Kuzzle, following the Kuzzle API format
reject
function
A Promise.reject function
resolve
function
A Promise.resolve function

queueFilter #

The queueFilter property must be set with a function of the following form:

Copied to clipboard!
boolean queueFilter(request)

The request argument is an object representing the request that is about to be sent to Kuzzle, following the Kuzzle API format.

queueMaxSize #

This property defines the size of the offline buffer, which is a first-in first-out (FIFO) queue.

This means that if the queueMaxSize limit is reached, older requests are discarded to make room for newer requests.

If queueMaxSize is set to a number lower than, or equal to 0, then an unlimited number of requests is kept in the offline buffer. Note that doing so may lead to a crash due to memory saturation, if there are too many requests held in memory.

queueTTL #

If the queueTTL property is set to a number lower than, or equal to 0, then requests never expire and are kept indefinitely.

volatile #

Multiple methods allow passing specific volatile data.

These volatile data will be merged with the global Kuzzle volatile object when sending the request, with the request specific volatile taking priority over the global ones.