-
-
Save lholmquist/ae12f397dcfaa1fb7e2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dm = AeroGear.DataManager(), | |
store1; | |
dm.add({ | |
name: "store1", | |
type: "IndexedDB", // this could be our SessionLocal/WebSQL/IndexedDB adapters, i don't think this really makes sense for the memory adapter | |
settings: { | |
sync: { // The sync option would probably only be for stores and not globally on the Data Manager | |
url: "URL_OF_SYNC_SERVER" | |
// future options like turning on "realtime" or other params for sync logic | |
// maybe an option to do a sync when the store is first created | |
// or does this happen on first read/save/remove/filter ? or does sync always just happen on read/save/remove/filter ? | |
// should probably happen on when doing the first operation | |
} | |
} | |
}); | |
store1 = dm.stores.store1; | |
store1.read({ | |
success: function( data, array_of_what_changed_during_sync ) { | |
// This array_of_what_changed_during_sync is similar to Object.observe's return http://updates.html5rocks.com/2012/11/Respond-to-change-with-Object-observe | |
// data here would be the new sync'd data | |
// success would only be called if there wasn't a conflict and things were sync'd successfully, like an auto merge | |
// .... | |
}, | |
error: function( error ) { | |
// Do we handle conflicts here, or should they be handled in a different callback? | |
// I kind of like a separate callback here | |
// ... | |
} | |
}); | |
// Same things would happen for save/remove/filter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment