SashiDo goes Realtime with Parse Server Live Queries

Peruna Keremidchieva

Before the concept of Live Queries (WebSockets behind the scenes) was created, developers used comet and long polling in order to simulate real time web. The problem was that this technologies needed almost constant communication with the server, which, as you’d imagine, it’s not very fast and resource-friendly.

Then Live Queries came and the Parse Server became realtime. Imagine an app game, which needs to update in real time non-stop. As you know, games should work very fast so every resource is important.

Why use Live Queries?

One of the key concepts behind Parse Server is the Query, which allows you to tell the Parse Server which object you need. If you want to use Live Queries you have to build a Query just like you normally would and instead of find() call subscribe(); This means that every time an object matching this query is changed, the server will see this immediately and push the new object data to you realtime.

Live Queries are part of the Parse Server and now they are also included and automated in SashiDo’s Dashboard and you can access and manipulate them easier that ever.

You can do so many things with them - updates, notifications, gaming, chats - everything will update in realtime! For example: you don’t necessarily need them for signing, user registration or other standard operation, but they are crucial if we talk about multiplayer gaming or realtime messaging and stuff.

How to set up Live Queries on SashiDo?

  1. Go to SashiDo’s Dashboard App settings -> Live Queries

  2. Choose the Class (in our case _User) you want to use Live Queries with and Save Changes

That’s it all! The setup is easy and effortless.

Benind the scenes

We know you're curious ... so here is what happens "behind the scenes" in case you had to do it by yourself:

We add liveQuery for class _User and a function to listen for the updates:

More info here:

Using Live Queries

Let's provide a LiveQuery client in our main JavaScript SDK (v1.8) and a separate client package for iOS.

We'll use JavaScript for the example. You have to use subscribe() instead of calling find() on a regular Query.

After that, if someone creates a new Player object that matches this query, with data like:

{
  objectId: 'rj9f032j0k',
  name: 'Mengyan',
  favoriteAthlete: 'INnoVation',
  league: 'Platinum'
}

Then the create event on the subscription will be triggered, and it will log INnoVation to the console.

And here is a simple page for quick tests if you don’t feel like doing the whole tutorial:

And if you want to play around with the code from the example, you can find it here:

As mentioned above, we have to use subscribe() to use Live Queries, but there’s also other events like delete, update, enter, error, leave.

Here are the Protocol-Specification and complete LiveQueries documentations for more detailed info so you can decide which one to use according to your use case.

We would love to see what you’ll build with this new feature, share it with us!

Happy coding :)

Peruna Keremidchieva

SashiDo's community manager & customer happiness freak.

Find answers to all your questions

Our Frequently Asked Questions section is here to help.