Symbyoz
  • Documentations
  • News
    • Access to Private and Public S3 bucket
    • Create manual database Backup
    • Parse Live Query on Symbyoz
    • Symbyoz back-office "white mark"
    • Cloud Code is now available in a Console
  • Tutorials
    • How to create a new project
    • How to create a custom module
    • How to manage left menu
    • How to manage admin user rights
  • Source code examples
    • Connect to iOS app
    • Connect to Android app
    • Create & Save Object
    • Get Object
    • Delete Object
    • User Management
    • Queries
    • Subclasses
    • Cloud Code
Powered by GitBook
On this page

Was this helpful?

  1. News

Parse Live Query on Symbyoz

PreviousCreate manual database BackupNextSymbyoz back-office "white mark"

Last updated 6 years ago

Was this helpful?

PFQuery is one of the key concepts for Parse. It allows you to retrieves PFObject by specifying some conditions, making it easy to build apps such as a dashboard, a todo list or even some strategy games. However, PFQuery is based on a PULL model, which is not suitable for apps that need real-time support.

Suppose you are building an app that allows multiple users to edit the same file at the same time like a Chat. PFQuery would not be an ideal tool since you can not know when to query from the server to get the updates.

To solve this problem, we introduce Parse LiveQuery. This tool allows you to subscribe to a PFQuery you are interested in. Once subscribed, the server will notify clients whenever a PFObject that matches the PFQuery is created or updated, in real-time.

Live Query is a PUSH model.

public void getLiveMessages()
{
        ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient();

        ParseQuery<ParseObject> queryMessage = ParseQuery.getQuery("Messages");

        SubscriptionHandling<ParseObject> messageChannel = parseLiveQueryClient.subscribe(queryMessage);

        // CHOOS ONLY ONE BETWEEN handleEvent and handleEvents
        messageChannel.handleEvents(new SubscriptionHandling.HandleEventsCallback<ParseObject>()
        {
            @Override
            public void onEvents(ParseQuery<ParseObject> query, SubscriptionHandling.Event event, ParseObject object)
            {
                // Triggered when an object from the class Messages is created, updated or deleted
                // use method handleEvent instead of handleEvents to get ONLY created object
            }
        });

}