-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RxDB observers emit data when results are not affected #31
Comments
@mnmtanish just to make sure I fully understood what you mean: Current behaviour: When a RxQuery is observed and the collection changes data, the full result of the query is emited again, even when it is not affected by the data-change. Your goal: When a RxQuery is observed and the collection changes data, the full result of the query is emited only if the query-result is affected by the data-change. Did I get this right? |
Yeah, although I'm not sure how to do it without slowing down RxDB. I thought of 2 ways to do this. I'm not sure which one will be faster or even whether RxDB needs this feature built into it. 1. Wrap the result observer function wrap(input: Observer<any>): Observer<any> {
let prev = null
return input.filter(data => {
if(deepEqual(data, prev)) {
return false
}
prev = data
return true
})
} 2. Re-run queries on changes I'm planning to use RxDB result observers with Angular2. I'm looking for a way to avoid unnecessary UI renders. I did hear that Angular2 is smart about tracking changes so maybe It'll be faster if Angular2 did this itself. I'll start the PR if you thinks it'll be good for RxDB. |
@mnmtanish could you confirm or deny that the test in b83da08 describes what you want? EDIT: Also check 39fbf5b |
Yes, 39fbf5b describes it |
@mnmtanish I released the version 2.0.0 which covers the test. Please check it out and tell me if all is ok. |
I tried RxDB with the localstorage adapter. If I create an observer for a query and subscribe and then edit a document which do not come under the query's result. The observer will emit the result data again. Is this something RxDB wishes to solve? If interested, I can start a pull-request for this.
The text was updated successfully, but these errors were encountered: