Sync localstorage with server strategy
Closed this issue · 6 comments
How about a way to dynamically change the sync-strategy during runtime with an example?
I am also interested in this.
+1
How would this work? I'm interested too.
Basically on the first fetch, use localSync
and then lookup updates on the server? What would the API look like?
Maybe it would help if I post my use case for this. I want to let both unregistered and registered users use my app. If the user is registered/logged-in, then use server sync. Otherwise, sync to local storage.
Well, that's easy. When the user is not registered, just set the localStorage
property in your collection or model, as written in the README.
For that class, it'll use the localStorage adapter, but if it's not present then it'll use the normal Backbone.sync method.
I am interested in this question too. You say "Well, that's easy", but you're not answering the question directly.
In our project, we need to create server bound collections, but a way to make it local temporarily, then make change it to a remote collection. The expected behaviour is that that local collection would sync itself with the server. See it like a local transaction, that is committed to the server.