pouchdb-hoodie-api icon indicating copy to clipboard operation
pouchdb-hoodie-api copied to clipboard

Challange: use PouchDB changes feed for events again

Open gr2m opened this issue 9 years ago • 0 comments

We once had a very simple, beautiful solution for events in pouchdb-hoodie-api: we started listening to PouchDB’s changes feed and used that to emit add, update and change events. But then we hit #54 which caused a timing issue, and after trying for a while to work around the problem while still using the changes feed, we eventually gave up. Instead of listening to the changes feed, we wrap all our methods and emit events manually, see changes here: https://github.com/hoodiehq/pouchdb-hoodie-api/pull/56/files

But I feel there is a better way, and it’s worth looking for it, it would remove a lot of complexity. And whoever finds a solution for this, gets a special Hoodie treat that I’ll have to make up first, but I promise it will be something nice <3

I’d suggest the following steps to get this started

  • [x] start a PR :clapper:
  • [x] Create a failing test and make it the only one that runs using test.only. Use only PouchDB & EventEmitter to reproduce the problem mentioned in #54. :red_circle:
  • [x] Find a solution :green_heart:
  • [ ] ~~Adjust the failing test to use pouchdb-hoodie-api APIs (see example in #54) :+1:~~ no longer relevant, the synchronous .hasLocalChanges() API has been removed
  • [x] Incorporate the solution, make sure all tests pass :clap:
  • [x] Review and merge :bow:

gr2m avatar Dec 19 '15 12:12 gr2m