-
-
Save mignev/4e013e7bfd0d615d738aec01ab5aad5d to your computer and use it in GitHub Desktop.
Live Queries setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<head> | |
<meta charset="utf-8"> | |
<title>SashiDo Live Queries Example!</title> | |
<meta name="description" content="My Parse App"> | |
<meta name="viewport" content="width=device-width"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
<script type="text/javascript" src="https://unpkg.com/parse@1.9.1/dist/parse.js"></script> | |
<style type="text/css"> | |
body {padding: 20px;} | |
</style> | |
</head> | |
<body> | |
<div class="row"> | |
<div class="col-sm-12"> | |
<h1>Live Query Result:</h1> | |
<pre id="json">Waiting for changes ...</pre></div> | |
</div> | |
<script type="text/javascript"> | |
/* | |
* Your credentials from: | |
* SashiDo Dashboard > You app > App Settings > Security & Keys | |
*/ | |
var server_url = 'https://pg-app-xxxxx.scalabl.cloud/1/', | |
app_id = 'xxxxxx', | |
javascript_key = 'xxxxx', | |
classname = '_User'; | |
Parse.initialize(app_id, javascript_key); | |
Parse.serverURL = server_url; | |
var ClassObject = Parse.Object.extend(classname); | |
var query = new Parse.Query(ClassObject); | |
var subscription = query.subscribe(); | |
subscription.on('create', function(obj) | |
{ | |
console.log('create', obj.attributes); | |
}); | |
subscription.on('update', function(obj) | |
{ | |
console.log('update', obj.attributes); | |
document.getElementById("json").innerHTML = JSON.stringify(obj.attributes, undefined, 2); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment