Skip to content

Bulk Update Listener

Listeners for bulk update work very similarly to the ones for single oject update. The differences between single object and bulk update include the method names to add and remove listener objects as well as the object delivered to the listener.

Conditional bulk update listener

When an API client executes a bulkUpdate API request using the same whereClause value as the one specified in addBulkUpdateListener, the listener receives a real-time event.

EventHandler<Map> eventHandler = Backendless.data.of("TABLE-NAME").rt();
eventHandler.addBulkUpdateListener(
     void Function(BulkEvent) callback,
    {String whereClause});
EventHandler<T> eventHandler = Backendless.data.withClass<T>().rt();
eventHandler.addBulkUpdateListener(
      void Function(BulkEvent) callback,
     {String whereClause});

Unconditional bulk update listener

A registered listener will receive a real-time request for all bulkUpdate API requests.

EventHandler<Map> eventHandler = Backendless.data.of("TABLE-NAME").rt();
eventHandler.addBulkUpdateListener(void Function(BulkEvent) callback);
EventHandler<T> eventHandler = Backendless.data.withClass<T>().rt();
eventHandler.addBulkUpdateListener(void Function(BulkEvent) callback);

For both conditional and unconditional update listeners, the BulkEvent object received in the callback contains the following properties:

  • whereClause - the where clause value used in the API call to identify the objects updated in the database.
  • count - the number of objects updated in the database.

Removing listeners

The method removes all registered listeners for the bulk update event:

eventHandler.removeBulkUpdateListeners();

The method below removes all listeners which process events for a specific where clause. The value of the whereClause argument must be the same as one in the addBulkUpdateListener method:

eventHandler.removeBulkUpdateListeners([String whereClause]);

Removing a specific listener

This method removes a listener identified by the callback object:

// for the class-based approach;
eventHandler.removeBulkUpdateListener(void Function(T) callback);

// for the map-based approach:
eventHandler.removeBulkUpdateListener(void Function(Map) callback);