diff --git a/lib/models.py b/lib/models.py index 9183619..38164d7 100644 --- a/lib/models.py +++ b/lib/models.py @@ -98,7 +98,7 @@ class Client(db.Model): class StateEntry(db.Model): last_set = db.DateTimeProperty(required=True, auto_now=True) entry_key = db.StringProperty(required=True) - entry_value = db.StringProperty(required=True) + entry_value = db.StringProperty() def ToMessage(self): return { @@ -114,3 +114,4 @@ class Subject(db.Model): class Subscription(db.Model): client = db.ReferenceProperty(reference_class=Client) + subject = db.ReferenceProperty(reference_class=Subject) diff --git a/static/cosmopolite.js b/static/cosmopolite.js index 3afc18c..5d224df 100644 --- a/static/cosmopolite.js +++ b/static/cosmopolite.js @@ -149,6 +149,12 @@ cosmopolite.Client.prototype.setValue = function(key, value) { 'key': key, 'value': value, }) + // Provide immediate feedback without waiting for a round trip. + // We'll also get a response from the server, so this should be eventually + // consistent. + if ('onStateChange' in this.callbacks_) { + this.callbacks_['onStateChange'](key, value); + } }; cosmopolite.Client.prototype.getValue = function(key) { diff --git a/static/debug.html b/static/debug.html index ac15b3f..08bb547 100644 --- a/static/debug.html +++ b/static/debug.html @@ -12,18 +12,32 @@ a {