JSFiddle - React, Tailwind, and code Playground
by lw7360
HTML
<script src="https://rawgit.com/pubnub/javascript/feature-pt74838232-3/web/pubnub.js"></script>
JavaScript
var settings = {
publish_key: "pub-c-bf446f9e-dd7f-43fe-8736-d6e5dce3fe67",
subscribe_key: "sub-c-d1c2cc5a-1102-11e4-8880-02ee2ddab7fe",
origin: "pubsub-beta.pubnub.com"
};
var pubnub = PUBNUB.init(settings);
var db = pubnub.sync("zzObj");
db.on.update(function (e) {
console.log("update");
console.log(e);
});
db.on.set(function (e) {
console.log("set");
console.log(e);
});
db.on.remove(function (e) {
console.log("remove");
console.log(e);
});
db.on.ready(function () {
pubnub.set({
object_id: "zzObj",
data: bigData,
callback: function () {
pubnub.set({
object_id: "zzObj",
callback: function () {},
data: bigData
});
}
});
});
var bigData = {
"home": {
"id": "HM4345831459",
"owner": {
"Bob": {
"lat": "",
"long": "",
"pulse": "73",
"steps": "2300",
"is_away": true
}
},
"address": "123 Easy Street",
"city": "Mountain View",
"zip": "94043",
"country": "USA",
"lat": "37.393162",
"long": "-122.067823",
"arrival-time": {
"id": "work-to-home",
"start": "18:30",
"end": "19:00"
},
"devices": {
"thermostat": {
"rest-409-v1": {
"device_version": "1.0",
"name": "indoor",
"description": "indoor thermostat in the hallway",
"is_online": true,
"is_powered_on": true,
"install_date": "2014-06-15T11:00:14",
"last_power_on": "2014-07-11T11:00:14",
"last_status_update": "2014-07-11T18:05:14",
"location":...