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
Client: automatic data structure sync i.e. .onValue(...)
#76
Conversation
subscription.onValue(...)
).onValue(...)
While testing this I updated the |
Oh and one other thing, |
I'm in the process of something similar and I've run up against the same questions:
I think it needs to know the sorting from the query. The current implementation of
I was leaning towards no. The idea with the onValue / values observable is that it takes care of the low-level details and just tells you what the resultset looks like. It's actually fine if the array gradually fills up to the size limit and your app renders things as they come in.
I was leaning towards not tacking it onto the subscription for this reason. Since this is inherently stateful, you really need to be able to ensure you've got the full results, and as you said, you don't want to save the state just in case the user needs it later. My thought was to add a method to
There are a good number of libraries around nowadays that use the convention of documenting that data structures should be considered immutable, but not enforcing it by being defensive with |
I think for the time being, I'm going to leave this unmerged, but I realize you need it or something like it for implementing the pagination api. My suggestion is to work with this on your private branch, and when I finish the observable state sync stuff, we can figure out how to put the pagination stuff on top of it |
This has now been implemented in #102 |
Implements #52. I went ahead and did this because in order to implement the pagination API (#31), we need to keep track of changefeed values to compute the page boundaries. There are a few open questions:
onValue
preserve sorting? Probably, and this is necessary for pagination anyway, butSubscription
currently knows nothing about the underlying query.onValue
subscribers be notified while we're receiving initial values? Tentatively, my vote would be no, but that's not how it's currently implemented.onValue
subscribers. The problem would be if you attach asubscription.onValue(...)
listener later on, the internal data structure wouldn't necessarily contain all/any initial values.onValue
currently emits a shallow copy of it's internal array. Does this need to be a deep copy? That will be more expensive, so it's something to think about.