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( String whereClause, AsyncCallback<BulkEvent> callback );
EventHandler<T> eventHandler = Backendless.Data.of( T.class ).rt();
eventHandler.addBulkUpdateListener( String whereClause, AsyncCallback<BulkEvent> callback );

Unconditional bulk update listener

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

EventHandler<Map> eventHandler = Backendless.Data.of( "TABLE-NAME" ).rt();
eventHandler.addBulkUpdateListener( AsyncCallback<BulkEvent> callback );
EventHandler<T> eventHandler = Backendless.Data.of( T.class ).rt();
eventHandler.addBulkUpdateListener( AsyncCallback<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( AsyncCallback<T> listenerObject );

// for the map-based approach:
eventHandler.removeBulkUpdateListener( AsyncCallback<Map> listenerObject );