Skip to content

Instantly share code, notes, and snippets.

@girliemac
Created December 5, 2014 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save girliemac/0be039191a5855f58204 to your computer and use it in GitHub Desktop.
Save girliemac/0be039191a5855f58204 to your computer and use it in GitHub Desktop.
Data Sync Demo
var home = pubnub.sync('home');
if(lightSwitchCheckbox.checked) {
// Light switch is turned on
home.merge({'light': true});
} else {
// Light switch is turned off
home.merge({'light': false});
}
home.on.merge(function(ref){
console.log(JSON.stringify(ref.value()));
lightSwitchCheckbox.checked = true; // sync UI across every devices
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment