Last active
December 30, 2015 05:39
-
-
Save edewit/7784495 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// [option 1 fully automatic we create a pipe and add the posibilty to add a store for failover and sync just happens at on- and offline events] | |
// and because merging can fail users can add a conflict handlers | |
Builder builder = Builder.createPipe(pipeConfig).addFailoverStore(storeConfig); | |
Pipe<Car> pipe = builder.pipe(Car.class); | |
pipe.addConfictHandler(new ConflictHandler() { | |
public void conflict(Field originalField, Field newField) { | |
// user interaction | |
} | |
}); | |
// [option 2 explicit let the user specify when to sync and what to sync] | |
SyncedPipe pipe = SyncPipeBuilder.build(options); // SyncPipe Store and Pipe togheter | |
// or we only use a store to sync and tell the sync manager where to sync to | |
SyncManager syncManager = new SyncManger(); | |
syncManger.filter(readFilter); // maybe we don't want to sync all data but just some part | |
syncManager.addConnectionHandler(new ConnectionHandler() { | |
public void onConnection() { | |
syncManger.sync(pipe); | |
} | |
}); | |
syncManger.addConfictHandler(new ConflictHandler() { | |
public void conflict(Field original, Field new) { | |
// user interaction | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment