erikolson186 / zangodb

MongoDB-like interface for HTML5 IndexedDB
https://erikolson186.github.io/zangodb/
MIT License
1.07k stars 72 forks source link

add change listener to collection? #8

Closed naivefun closed 7 years ago

naivefun commented 7 years ago

It would be great if there is:

collection.on('change', e => ...);

or other events like creation delete ...

erikolson186 commented 7 years ago

It would be nice. There is a problem though: IndexedDB does not emit events for changes to object stores (collections) yet allows for multiple connections to a given database. This means that the events you proposed could not be ensured to be emitted for changes across connections.

I would instead recommend emitting these events in your own code. This way certain assumptions could be made regarding how your own databases are used.