Status of a local to remote replication

11 views
Skip to first unread message

Foucauld Degeorges

unread,
Sep 18, 2015, 11:08:47 AM9/18/15
to PouchDB
Hello,

I've been trying to figure out how to correctly monitor the status of a push replication. My goal is to be able to tell the user whether the replication is "Up to Date", "Syncing" or "Offline" at any moment.
I've figured out how to use the active and paused events to be able to tell between "Up to Date" and "Syncing".
"Offline" means that no connection can be established with the remote, but that seems more delicate : since the changes are pushed to remote, no network request happens between changes ; thus, we don't know if we're "Offline" until there actually is a change, do we ?
Did anyone have this problem and find a solution?

Thanks
Foucauld Degeorges

Dale Harvey

unread,
Sep 18, 2015, 11:12:59 AM9/18/15
to pou...@googlegroups.com
The paused event also has an error parameter sent to it, so

replication.on('paused', function(err) {
  if (err) {
    // You are likely offline, or there was some problem
  } else {
    // You are waiting for more changes
  }
});

There have been some reports of these events not being 100% reliable, but I am working on them right now, if you have any issues with them would love to hear.

Cheers
Dale

--
You received this message because you are subscribed to the Google Groups "PouchDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pouchdb+u...@googlegroups.com.
To post to this group, send email to pou...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pouchdb/410e23a2-8dbf-496a-b70c-0df76ad76b1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages