Skip to content

Commit

Permalink
avoid sharing databases between tabs so replication has to transfer a…
Browse files Browse the repository at this point in the history
…ctual documents!
  • Loading branch information
natevw committed Oct 15, 2013
1 parent 7be3a44 commit e613136
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions webrtc_test.html
Expand Up @@ -24,8 +24,9 @@ <h1>PeerPouch: PouchDB-over-WebRTC</h1>
<pre>TBD: log to here / simple demo</pre>

<script>
var HUB_URL = "http://peerpouch-test.ipcalf.com",
SHARE_URL = "idb://peerpouch-test";
var NAME = location.hash.slice(1) || "noname",
HUB_URL = "http://peerpouch-test.ipcalf.com",
SHARE_URL = "idb://peerpouch-test-"+NAME;

queue()
.defer(PouchDB, HUB_URL)
Expand All @@ -35,13 +36,13 @@ <h1>PeerPouch: PouchDB-over-WebRTC</h1>
window.dbgLocal = local; // expose for console inspection

setInterval(function () {
var id = location.hash.slice(1)+'_at_'+Date.now();
var id = NAME+'_at_'+Date.now();
local.put({_id:id});
}, 15e3);

local.changes({since:'latest', continuous:true, onChange:function (chg) {
var src = chg.id.split('_at_')[0];
if (src !== location.hash.slice(1)) console.log("Got non-local change", chg.id);
if (src !== NAME) console.log("Got non-local change", chg.id);
}});

// share our local database
Expand All @@ -60,7 +61,6 @@ <h1>PeerPouch: PouchDB-over-WebRTC</h1>

console.log("Opened remote", remote);

// NOTE: the replicator doesn't seem to call our onChange loggers much/ever
PouchDB.replicate(remote, local, {continuous:true, onChange:function (change) {
console.log("RX CHANGE FROM REMOTE", change);
}});
Expand Down

0 comments on commit e613136

Please sign in to comment.