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.
var eventHandler = Backendless.Data.Of( "TABLE-NAME" ).RT();
eventHandler.AddBulkUpdateListener( whereClause, ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsUpdated( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// the where clause for which the bulk event has been triggered
// the value can be used to retrieve the updated objects from the database
public String WhereClause { get; }
// number of updated objects
public int Count { get; }
}
}
var eventHandler = Backendless.Data.Of<T>().RT();
eventHandler.AddBulkUpdateListener( whereClause, ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsUpdated( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// the where clause for which the bulk event has been triggered
// the value can be used to retrieve the updated objects from the database
public String WhereClause { get; }
// number of updated objects
public int Count { get; }
}
}
Unconditional bulk update listener¶
A registered listener will receive a real-time request for all bulkUpdate
API requests.
var eventHandler = Backendless.Data.Of( "TABLE-NAME" ).RT();
eventHandler.AddBulkUpdateListener( ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsUpdated( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// this value will be null for the unconditional bulk update event listener
public String WhereClause { get; set; }
// number of updated objects
public int Count { get; set; }
}
}
var eventHandler = Backendless.Data.Of<T>().RT();
eventHandler.AddBulkUpdateListener( ( bulkEvent ) =>
{
});
public delegate void MultipleObjectsUpdated( BulkEvent bulkEvent );
namespace BackendlessAPI.RT.Data
{
public class BulkEvent
{
// this value will be null for the unconditional bulk update event listener
public String WhereClause { get; set; }
// number of updated objects
public int Count { get; set; }
}
}
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:
eventHandler.RemoveBulkUpdateListener( MultipleObjectsUpdated callback );