-
Notifications
You must be signed in to change notification settings - Fork 108
Syncing all dirty models #108
Description
I have a scenario where I have a Collection of Jobs and when navigating into a job, I request a collection of services.
The URL of the services collection is …/services/12345 and such its offline store name is …/services/12345_dirty.
When the app comes back online and I want to sync everything that has changed. To do this I create dummy Jobs and Services collections and execute syncDirtyAndDestroyed.
This approach works fine for Jobs because there is no dynamic element to the URL but services sync never completes due to the URL parameter.
I see two solutions check for and parse any '_dirty' elements in localstorage, create each matching collection in turn the sync or maintain a reference to all the services collection that are created then iterate over them to perform the sync. Both options seem rather crude.
Is there currently support for global syncs in the fashion is described?
// perform global sync.
var that = this;
var jobsSync = new app.collections.JobsCollection()).fetch({
success: function (collection, resp, options) {
collection.syncDirtyAndDestroyed();
}
});
var servicesSync = new app.collections.ServicesCollection().fetch({
success: function (collection, resp, options) {
collection.syncDirtyAndDestroyed();
}
});