addListener

var callback = function () {
    // Actions to perform when receiving a 'connected' global event
  };
  kuzzle.addListener('connected', callback);
EventListener eventListener = new EventListener() {
  @Override
  public void trigger(Object... args) {
    // Actions to perform when receiving a 'subscribed' global event
  }
};
kuzzle.addListener(Event.connected, eventListener);
<?php

$kuzzle->addListener('queryError', function() {
  // Actions to perform when receiving a 'queryError' global event
});

Adds a listener to a Kuzzle global event. When an event is fired, listeners are called in the order of their insertion.

See the event handling section for a full events list.


addListener(event, listener)

ArgumentsTypeDescription
eventstringOne of the event described in the Event Handling section of this documentation
listenerfunctionThe function to call each time one of the registered event is fired

Return value

Returns the Kuzzle object to allow chaining.