Live Query

Live Query allows you to subscribe to a Parse.Query you are interested in. Once subscribed, the server will notify clients whenever a Parse.Object that matches the Parse.Query is created or updated, in real-time.

Suppose you're building a To Do app and multiple users can make edits to the list. Parse.Query would require you to constantly poll the server for status. That's not an ideal situation.

A Live Query solves this and makes it to where the client can subscribe to a Parse.Query and when updates are made, the subscriber will be notified.

Setup

Live Query requires you to configure which collections can be subscribed to. There are two ways to configure collections, env.json and live-query-classnames hook.

env.json

Open the /src/env.json file and update the LIVE_QUERY_SETTINGS.classNames array with the collection name you wish to include.

/src/env.json
{
    ...
    "LIVE_QUERY_SERVER": true,
    "LIVE_QUERY_SETTINGS": {
        "classNames": ["Changelog", "YourCollection"]
    },
    ...
}

If you have multiple env.json files be sure to update them accordingly

live-query-classnames hook

/src/app/MyPlugin/plugin.js
Actinium.Hook.register('live-query-classnames', classNames => {
    classNames.push('MyPluginCollection'); 
});

Using the live-query-classnames hook will execute regardless of your plugin's active status due to the fact that this hook is run before the server starts.

Last updated