PeerPouch icon indicating copy to clipboard operation
PeerPouch copied to clipboard

Update to 3.0.5 api, intermediate work

Open ssured opened this issue 11 years ago • 6 comments

I'm trying to get this plugin to work with the new PouchDB 3.0.5. Half success is accomplished, two browser can talk over the data channel to each other, but the exchanged rpcAPI object does not work for me. I get a this._bulkDocs(...) is undefined error when writing anything to the remote DB. My guess is there are changes to AbstractPouchDB on how custom adapters are registered, but from reading the source I could not figure this out. Your entry https://github.com/pouchdb/pouchdb/wiki/Writing-custom-adapters is the only thing I can find.

It would be cool to get this to work. More browsers are supporting webRTC, so it will become a real communication channel. My wish is syncing a mobile Chrome to a desktop Chrome, without having an intermediate server located database.

ssured avatar Sep 16 '14 12:09 ssured

+1 :-)

dahjelle avatar Sep 19 '14 17:09 dahjelle

Thanks for starting this! I wonder if mainly the list of methods at https://github.com/ssured/PeerPouch/blob/efd896ff5bc30e4b2684b79e544bd6c2ee1e2609/pouch.webrtc.js#L78 just needs to be adjusted?

You probably noticed this already, but PeerPouch is implemented as an RPC system rather than a protocol. When you're using a remote DB locally, you're calling a (local) adapter whose methods just forward over to the remote instance for any actual processing. (And vice versa…the remote instance gets a proxy of all your callbacks.)

There were a few assumptions that this relies on — no synchronous return values [IIRC I worked around one or two unavoidable situations] and callbacks generally only called once [again there are a few places where exceptions are made]. Maybe the addition of Promises to PouchDB will require a bigger adjustment too.

Side note: would it be possible to put back the indented blank lines, or at least commit the whitespace changes separately? I'm guessing your editor makes that happen for you, but it's harder to review due to all that noise.

natevw avatar Oct 10 '14 17:10 natevw

Hi Nate, this code was more or less just to save a little of my work, it's nowhere complete. About the whitespace, see https://github.com/blog/967-github-secrets, which tells about the ?w=1 param. Appending it to a diff url, it will strip all whitespace changes from a diff. See https://github.com/natevw/PeerPouch/pull/12/files?w=1.

The RPC implementation was clear to me. It's the easiest approach. Maybe the streaming protocol which is being developed will be even better suited, but thats not finished yet...

ssured avatar Oct 13 '14 11:10 ssured

Ah, cool tip on the whitespace, thanks!

natevw avatar Oct 14 '14 20:10 natevw

I'm happy to announce that pouchdb-replication-stream now runs in the browser. So it should be pretty easy to fix this plugin up to use that instead. :)

nolanlawson avatar Feb 22 '15 19:02 nolanlawson

Great work @nolanlawson! This opens up a whole new set of possibilities :+1:

ssured avatar Feb 22 '15 19:02 ssured