-
Notifications
You must be signed in to change notification settings - Fork 108
Set options.dirty
to true
if reading locally due to dirty collection
#105
Comments
I'm in favor of this. |
Here's a diff: elad/Backbone.dualStorage@master...remote_local_fixes The base is my master branch which already has the fixes discussed in the other issue (offline status handling) since I need it for my app. What it does:
|
Thanks! (I was about to look into this today since I remembered seeing this feature documented but not implemented!) |
Hang tight, I'm rewriting the merge since I messed something up. :P |
I cherry-picked the options.dirty commit and fixed it so that options.dirty gets set when the browser is offline (related to #104). I think it would be better to implement |
Also for these methods please add integration tests (use the external API and don't mock anything) so that we can ensure they continue to work after the backend is switched. |
You're right about the importance of abstraction here, I completely forgot about the 2.5mb localStorage limit... I'll take care of it and add the relevant tests. By the way, I'm not sure |
okay. Feel free to remove that. |
Released in 1.3.0 |
Hey, Sorry for getting back to this after so long... When you talk about implementing (I'm asking because the implementation of all functions on |
I wouldn't want to expose anything new on the collection. My thought was to make With Store implemented like this, then all the collection methods can be implemented as such, not needing to know about localStorage or the suffixes: dirty = new Store(getStoreName(this)).dirtyRecords()
ids = (dirty and dirty.split(',')) or [] |
Do you mean something along these lines? Collection:
Store:
(edited to add missing functions discussed above.) |
The documentation states that if a collection is dirty,
fetch
will read from localStorage. This is fine, but similar to how other places setoptions.dirty
totrue
to indicate the operation happened locally, I feel the same should happen here. Then the pattern of testingoptions.dirty
in the success callback is consistent across all CRUD methods.It looks like this is a simple change in
dualsync
to addoptions.dirty = true
below theif localsync('hasDirtyOrDestroyed', model, options)
line.Comments?
The text was updated successfully, but these errors were encountered: