angular-pouchdb icon indicating copy to clipboard operation
angular-pouchdb copied to clipboard

adapt pouchdb.changes() to pouchdb 3 event handler

Open andrenarchy opened this issue 11 years ago • 4 comments

PouchDB 3 introduced a new API for changes() which now returns an event emitter. The wrapped changes function now also makes use of angular's $q and uses the notify callback if more than one change is expected (e.g., with live: true). Furthermore, the promise is called with an object containing both the change (containing the data) and the changes object (which may be useful for cancelling the subscription).

The new version can, e.g., be used as follows:

var db = pouchdb.create('mydb');
db.changes({live: true}).then(null, null, function (res) {
  // access res.change or res.changes
  // e.g., cancel via res.changes.cancel()
});

andrenarchy avatar Sep 25 '14 09:09 andrenarchy

:+1: I experienced an issue using changes() with a newer version of pouchdb and angular-pouchdb today.

The library is expecting onChange() to be passed as an option and appears to fail if it's not passed. It appears this method is deprecated and may be removed in pouchdb 3.0

adamduren avatar Nov 05 '14 05:11 adamduren

@wspringer: is there any reason for not merging the PR?

andrenarchy avatar Nov 05 '14 09:11 andrenarchy

@andrenarchy

@wspringer isn't actively maintaining the project currently so hopefully someone else can help you out here. :)

NickColley avatar Nov 05 '14 18:11 NickColley

@andrenarchy - You might consider looking at https://github.com/jrhicks/ngPouch - It simplifies working with pouchdb in an Angular app by publishing replication status, managing progressive reconnections, and assisting 3 way binding.

jrhicks avatar Nov 05 '14 18:11 jrhicks