Hi @mike-turner
If in terms of your leaderboard table max score can be either CREATED or UPDATED - then you should use both create
and update
listeners. Basically there are 2types of listeners: conditional and unconditional. Unconditional subscribes to ALL create
and update
events in a certain table while conditional ones are triggered only when specified condition is met. F.e.:
EventHandler<Map> orderEventHandler = Backendless.Data.of( "LeaderBoard" ).rt();
orderEventHandler.addCreateListener( "maxScore > 1000", new AsyncCallback<Map>()
{
//your handleResponse and handleFault blocks
}
In this case listener will be triggered only in case if maxScore of created object is higher than 1000.
Same for update
listener.
In order to keep leaderboard “fresh” - retrieve objects from leaderboard table with DESC sorting by maxScore column. Any update or create event will trigger a listener. Whether the object is created/updated from iOS SDK, Android, REST or even Data console. Nothing special or extra should be done, listeners are just interceptors.
More about listeners, listeners triggering etc you can read in docs:
JS (for web) - Handlers, Events and Listeners - Backendless SDK for JavaScript API Documentation
Android (just in case) - Handlers, Events and Listeners - Backendless SDK for Android/Java API Documentation
iOS (just in case) - Handlers, Events and Listeners - Backendless SDK for iOS API Documentation
THESE articles also might be helpful, on of them even has leaderboard example :
Regards,
Anton