You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
For perf reasons, our API accepts a since parameter and only returns items that have changed since that time (typically it's the last time that the particular client has synced), so that we can update only the models that have changed on the client.
When fetching from the API in this way, we need to pass {remove: false} to the fetch (this is so that the unchanged items are not removed from the collection).
The issue here is that all items which were not included in that fetch's response are removed from localstorage (essentially ignoring the {remove: false} option that we've set on the fetch), so even though the collection has all the items at this point, the next time you fetch from localstorage, they will be gone, and you'll only end up with the items that were returned from the last fetch.
Is there an alternative method to accomplish this sort of thing using Backbone.dualStorage? If not, would it be trivial enough to store the actual collection's models in localstorage (after a fetch) rather than just the request's response data?
The text was updated successfully, but these errors were encountered:
Yes, you're right that dualStorage does not currently account for remove: false. I don't know of any workaround for your situation. We should add support for this option when fetching collections.
localsync('clear', model, options) unless options.add or options.remove == false
I do not have time to test this out right now. First, see if this change fixes your specific issue in your project, and report back. If possible, please create a pull request that adds a unit and/or integration test that reproduces this failure before a fix is applied, and with the fix, if it works. See the README for test and build instructions.
For perf reasons, our API accepts a
since
parameter and only returns items that have changed since that time (typically it's the last time that the particular client has synced), so that we can update only the models that have changed on the client.When fetching from the API in this way, we need to pass
{remove: false}
to the fetch (this is so that the unchanged items are not removed from the collection).The issue here is that all items which were not included in that fetch's response are removed from localstorage (essentially ignoring the
{remove: false}
option that we've set on the fetch), so even though the collection has all the items at this point, the next time you fetch from localstorage, they will be gone, and you'll only end up with the items that were returned from the last fetch.Is there an alternative method to accomplish this sort of thing using Backbone.dualStorage? If not, would it be trivial enough to store the actual collection's models in localstorage (after a fetch) rather than just the request's response data?
The text was updated successfully, but these errors were encountered: