From 65c4710f02892f4007dc3681d96c432dfa246804 Mon Sep 17 00:00:00 2001 From: Andres Jaan Tack Date: Thu, 30 Nov 2017 15:48:52 +0200 Subject: [PATCH] Update to Sync SDK v0.7. --- static/sync/index.html | 2 +- static/sync/index.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/static/sync/index.html b/static/sync/index.html index 796886d..4096d63 100755 --- a/static/sync/index.html +++ b/static/sync/index.html @@ -44,7 +44,7 @@ - + diff --git a/static/sync/index.js b/static/sync/index.js index 1cc3728..b260c7b 100755 --- a/static/sync/index.js +++ b/static/sync/index.js @@ -26,14 +26,17 @@ $(function () { //Note the use of promises syncClient.document('SyncGame').then(function(syncDoc) { //Initialize game board UI to current state (if it exists) - var data = syncDoc.get(); + var data = syncDoc.value; if (data.board) { updateUserInterface(data); } //Let's subscribe to changes on this document, so when something //changes on this document, we can trigger our UI to update - syncDoc.on('updated', updateUserInterface); + syncDoc.on('updated', function(event) { + console.debug("Board was updated", event.isLocal? "locally." : "by the other guy."); + updateUserInterface(event.value); + }); //Whenever a board button is clicked, update that document. $buttons.on('click', function (e) {