Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork132
Parse LiveQuery Client for iOS/OS X.
License
parse-community/ParseLiveQuery-iOS-OSX
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
⚠️ The LiveQuery feature has been added as a module to theParse Apple SDK. This repository is archived and will no longer receive any updates.
PFQuery is one of the key concepts for Parse. It allows you to retrievePFObjects 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.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 aPFQuery you are interested in. Once subscribed, the server will notify clients whenever aPFObject that matches thePFQuery is created or updated, in real-time.
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 theOpen Source Parse Server.
You can install the LiveQuery client via including it in your Podfile:
pod 'ParseLiveQuery'The LiveQuery client interface is based around the concept ofSubscriptions. You can register anyPFQuery for live updates from the associated live query server, by simply callingsubscribe() on a query:
letmyQuery=Message.query()!.where(....)letsubscription:Subscription<Message>=Client.shared.subscribe(myQuery)
WhereMessage is a registered subclass of PFObject.
Once you've subscribed to a query, you canhandle events on them, like so:
subscription.handleEvent{ query, eventin // Handle event}
You can also handle a single type of event, if that's all you're interested in:
// Note it's handle(), not handleEvent()subscription.handle(Event.created){ query, objectin // Called whenever an object was created}
By default, it will print the logs from WebSocket / WebSocketDelegate. You can turn it off:
Client.shared.shouldPrintWebSocketLog=false
You can also enable socket trace messages for all sent and received strings. By default, these trace messages are disabled.
Client.shared.shouldPrintWebSocketTrace=true
Handling errors is and other events is similar, take a look at theSubscription class for more information.
You are not limited to a single Live Query Client - you can create your own instances ofClient to manually control things like reconnecting, server URLs, and more.
We want to make contributing to this project as easy and transparent as possible. Please refer to theContribution 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 iOS/OS X.
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.