Unconditional Delivery Listeners¶
The where clause
argument in the addUpdateListener
method is optional. When it is not provided, the real-time database will deliver any object which is being updated in the database's table:
EventHandlerForClass *eventHandler = [Backendless.shared.data of:[Order class]].rt;
RTSubscription *subscription = [eventHandler addUpdateListenerWithResponseHandler:^(Order *updatedObject) {
NSLog(@"Order has been updated: %@", updatedObject);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
let eventHandler = Backendless.shared.data.of(Order.self).rt
let subscription = eventHandler?.addUpdateListener(responseHandler: { updatedObject in
print("Order has been updated: \(updatedObject)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
EventHandlerForMap *eventHandler = [Backendless.shared.data ofTable:@"Order"].rt;
RTSubscription *subscription = [eventHandler addUpdateListenerWithResponseHandler:^(NSDictionary *updatedObject) {
NSLog(@"Order has been updated: %@", updatedObject);
} errorHandler:^(Fault *fault) {
NSLog(@"Error: %@", fault.message);
}];
let eventHandler = Backendless.shared.data.ofTable("Order").rt
let subscription = eventHandler?.addUpdateListener(responseHandler: { updatedObject in
print("Order has been updated: \(updatedObject)")
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
})
Codeless Reference¶
where:
Argument | Description |
---|---|
id |
Unique identifier of the new event listener. |
table name |
The name of the data table where a conditional event listener must be registered. |
where clause |
Optional parameter. Sets the condition for an event listener which gets triggered every time the condition is met when the update operation is invoked for a specific data table. For more information about the where clause syntax, see the Condition Syntax section of the guide. |
object |
When a listener gets triggered, the Backendless delivers a callback object containing the updated object to the listener. |
The example below registers a new event listener for the "Person"
data table with the id``"1EFD-3GEF2-FF4C-AC21"
. The listener is triggered when an existing object is updated in the data table.
Assume an object in the data table is updated, and the Codeless logic below executes a custom block of code; First the following sentence is printed: "Update operation has triggered the listener."
, then the value of the property objectId
is retrieved from the object
variable and also gets printed.