SDK Java v2.x

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.

subscribe #

Listens to changes occuring in this document. Throws an error if this document has not yet been created in Kuzzle.

The provided callback will be called everytime a notification is received from Kuzzle.

subscribe([options], callback) #

Arguments Type Description
options object Subscription configuration
callback function Callback that will be called each time a change has been detected on this document

Options #

Options are directly passed to the Room object constructor.

Return Value #

Returns an object exposing the following method: onDone(callback)

The callback argument is called when the subscription ends, either successfully or with an error.

Usage #

Copied to clipboard!
Room room = document.subscribe(new ResponseListener<NotificationResponse>() {
  public void onSuccess(NotificationResponse object) {
    // called each time a change occurs on this document
  public void onError(JSONObject error) {
    // Handle error
  .onDone(new ResponseListener<Room>() {
    public void onSuccess(Room response) {
      // Handle subscription success
    public void onError(JSONObject error) {
      // Handle subscription error