Skip to content

Instantly share code, notes, and snippets.

@anidotnet
Created May 11, 2017 03:35
Show Gist options
  • Save anidotnet/d9fa509d4b6c104cb5b7aac8e3f00d66 to your computer and use it in GitHub Desktop.
Save anidotnet/d9fa509d4b6c104cb5b7aac8e3f00d66 to your computer and use it in GitHub Desktop.
Nitrite Introduction
// connect to a DataGate server localhost 9090 port
DataGateClient dataGateClient = new DataGateClient("http://localhost:9090")
.withAuth("userId", "password");
DataGateSyncTemplate syncTemplate
= new DataGateSyncTemplate(dataGateClient, "remote-collection@userId");
// create sync handle
SyncHandle syncHandle = Replicator.of(db)
.forLocal(collection)
// a DataGate sync template implementation
.withSyncTemplate(syncTemplate)
// replication attempt delay of 1 sec
.delay(timeSpan(1, TimeUnit.SECONDS))
// both-way replication
.ofType(ReplicationType.BOTH_WAY)
// sync event listener
.withListener(new SyncEventListener() {
@Override
public void onSyncEvent(SyncEventData eventInfo) {
}
})
.configure();
// start sync in the background using handle
syncHandle.startSync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment