GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - parse-community/ParseLiveQuery-Android: Parse LiveQuery client for Android.

BranchesTags
Open more actions menu

Latest commit

 

History

76 Commits
76 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
ParseLiveQuery
ParseLiveQuery
 
 
gradle/wrapper
gradle/wrapper
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
PATENTS
PATENTS
 
 
README.md
README.md
 
 
THIRD_PARTY_NOTICES.txt
THIRD_PARTY_NOTICES.txt
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Parse LiveQuery Client for Android

License Build Status

ParseQuery is one of the key concepts for Parse. It allows you to retrieve ParseObjects by specifying some conditions, making it easy to build apps such as a dashboard, a todo list or even some strategy games. However, ParseQuery 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. ParseQuery 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 ParseQuery you are interested in. Once subscribed, the server will notify clients whenever a ParseObject that matches the ParseQuery is created or updated, in real-time.

Setup Server

Parse LiveQuery contains two parts, the LiveQuery server and the LiveQuery clients. In order to use live queries, you need to set up both of them.

The easiest way to setup the LiveQuery server is to make it run with the Open Source Parse Server.

Dependency

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Then, add the library to your project build.gradle

dependencies {
    implementation 'com.github.parse-community:ParseLiveQuery-Android:latest.version.here'
}

Use Client

The LiveQuery client interface is based around the concept of Subscriptions. You can register any ParseQuery for live updates from the associated live query server, by simply calling subscribe() on the client:

// Parse.initialize should be called first

ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient();

Creating Live Queries

Live querying depends on creating a subscription to a ParseQuery:

ParseQuery<Message> parseQuery = ParseQuery.getQuery(Message.class);

SubscriptionHandling<ParseObject> subscriptionHandling = parseLiveQueryClient.subscribe(parseQuery)

Once you've subscribed to a query, you can handle events on them, like so:

subscriptionHandling.handleEvents(new SubscriptionHandling.HandleEventsCallback<ParseObject>() {
    @Override
    public void onEvents(ParseQuery<ParseObject> query, SubscriptionHandling.Event event, ParseObject object) {
        // HANDLING all events
    }
})

You can also handle a single type of event, if that's all you're interested in:

subscriptionHandling.handleEvent(SubscriptionHandling.Event.CREATE, new SubscriptionHandling.HandleEventCallback<ParseObject>() {
    @Override
    public void onEvent(ParseQuery<ParseObject> query, ParseObject object) {
        // HANDLING create event
    }
})

Handling errors is and other events is similar, take a look at the SubscriptionHandling class for more information.

Advanced Usage

If you wish to pass in your own OkHttpClient instance for troubleshooting or custom configs, you can instantiate the client as follows:

ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient(new OkHttp3SocketClientFactory(new OkHttpClient()));

The URL is determined by the Parse initialization, but you can override by specifying a URI object:

ParseLiveQueryClient parseLiveQueryClient = ParseLiveQueryClient.Factory.getClient(new URI("wss://myparseinstance.com"));

Note: The expected protocol for URI is ws instead of http, like in this example: URI("ws://192.168.0.1:1337/1").

How Do I Contribute?

We want to make contributing to this project as easy and transparent as possible. Please refer to the Contribution Guidelines.


As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.

About

Parse LiveQuery client for Android.

Topics

livequery-clientsparse-live-queryparse-platform

Resources

Readme
License

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

86 stars

Watchers

16 watching

Forks

33 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.