Created
May 11, 2017 03:35
-
-
Save anidotnet/d9fa509d4b6c104cb5b7aac8e3f00d66 to your computer and use it in GitHub Desktop.
Nitrite Introduction
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
// 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