-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for single global changes feed #25
Conversation
… collections / names with paths - janmonschke#17
… filter functions
Have you run the tests on that? |
Hi Jan, we have our own cucumber features and jasmine specs which we've run and confirmed the behavior is as expected, but I did not write any specific tests for just the connector. I confirmed multi-browser/window support manually as this is currently hard to test in an automated way. As I noted above, if this is a long-term feature you'd like to support then the code could probably be refactored to be simpler, I just wanted to make a minimal amount of changes for a patch. |
I would simply merge this if you could also provide the changes to the readme :) |
I found the changes in this pull request essential, because I have several object instances listening for changes. But, merging this pull request into my project meant reverting from backbone-couchdb 1.2.2 to 1.1. So, I'm updating the readme (and will provide a pull request) in the hope this will make it possible to pull these changes into a future version of backbone-couchdb. I know this will require a bit of tricky merge work by someone who knows the code well. In other words, I think the way to integrate these changes into the mainline is to merge them with the 1.1 code, then merge in each subsequent revision which resulted in 1.2.2, then release a new version named 1.2.3 or 1.3, since this is a new feature. I'm not confident I can do this tricky merge work, because I don't understand the code well. |
I attempted to further this work in pull request #55. |
…janmonschke/backbone-couchdb#25 to provide a single global changes feed to avoid hitting the browser's concurrent requests per server limit, modify code to work with backbone-relational.js
…janmonschke/backbone-couchdb#25 to provide a single global changes feed to avoid hitting the browser's concurrent requests per server limit, modify code to work with backbone-relational.js
This patch adds support for a single global changes feed (it also includes my previous patch for conservative collection name derivation, although that is trivial to separate).
The global feed is enabled like:
When the single global feed is enabled, the way collection change handlers are registered is changed. (Whether they are registered has not been changed, and is still governed by the
global_changes
or individual collectionchanges
setting.)When single feed is enabled, each collection handler will be registered with a single changes feed.
Each collection also supports a
local_filter
irrespective of the single feed. Thislocal_filter
function can be used to, you guessed it, filter change results from the changes feed. When coupled with the single changes feed this allows each collection to only observe relevant changes. When single feed is enabled, a default local filter is installed which does this (so if you follow standard conventions you should be able to just enablesingle_feed
).Default single_feed local_filter:
Example of custom local_filter:
On a technical note, change listener registration could probably be factored out into a separate class that is reused for both the per-collection and global feed, but I wanted my changes to be minimal.