New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pusher real-time updates. #1
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
$(document).ready(function() { | ||
|
||
// Mozilla demo server (flushed every day) | ||
var server = "https://kinto.dev.mozaws.net/v1"; | ||
|
||
// Pusher app key | ||
var pusher_key = "01a9feaaf9ebb120d1a6"; | ||
|
||
// Simplest credentials ever. | ||
var authorization = "Basic " + btoa("public:notsecret"); | ||
|
||
|
@@ -11,6 +14,12 @@ $(document).ready(function() { | |
// Local store in IndexedDB. | ||
var store = kinto.collection("kinto_demo_calendar"); | ||
|
||
// Live changes. | ||
var pusher = new Pusher(pusher_key, { | ||
encrypted: true | ||
}); | ||
|
||
|
||
// | ||
// Initialize fullCalendar | ||
// | ||
|
@@ -162,4 +171,12 @@ $(document).ready(function() { | |
throw err; | ||
}); | ||
} | ||
|
||
// This is the default bucket id for the ``public:notsecret`` user on kinto.dev | ||
var channelName = '94b660c6-68f3-83c4-97fa-8e8ac4715204-kinto_demo_calendar-record'; | ||
var channel = pusher.subscribe(channelName); | ||
channel.bind_all(function() { | ||
syncServer(); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :) that'd work indeed |
||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.2/moment.min.js"></script> | ||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.0/fullcalendar.css" /> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.0/fullcalendar.js"></script> | ||
<script src="https://js.pusher.com/3.0/pusher.min.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to work yes. |
||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum. I prefer this way actually : https://github.com/leplatrem/cliquet-pusher/blob/master/demo/map.js#L102-L115
If you don't (which I would understand since concise code is cool), then put it into a top variable, and use it to build the channel name. Same for collection id actually :)