GithubHelp home page GithubHelp logo

rlugojr / parselivequery-ios-osx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from parse-community/parselivequery-ios-osx

0.0 2.0 0.0 112 KB

Parse LiveQuery Client for iOS/OS X.

License: Other

Ruby 5.17% Swift 91.61% Objective-C 3.22%

parselivequery-ios-osx's Introduction

Parse LiveQuery Client for iOS/OSX

Platforms Carthage compatible

Podspec License

Build Status

PFQuery is one of the key concepts for Parse. It allows you to retrieve PFObjects 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 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.

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.

Install Client

Cocoapods

You can install the LiveQuery client via including it in your Podfile:

pod 'ParseLiveQuery'

Use Client

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

let myQuery = Message.query()!.where(....)
let subscription: Subscription<Message> = myQuery.subscribe()

Where Message is a registered subclass of PFObject.

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

subscription.handleEvent { query, event in
    // Handle event
}

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

subscription.handle(Event.Created) { query, object in
    // Called whenever an object was created
}

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

Advanced Usage

You are not limited to a single Live Query Client - you can create your own instances of Client to manually control things like reconnecting, server URLs, and more.

How Do I Contribute?

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

parselivequery-ios-osx's People

Contributors

agordeev avatar flovilmart avatar kajensen avatar nlutsenko avatar noobs2ninjas avatar richardjrossiii avatar vstepanyuk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.