'Hello World' Sync
Once you've set up your environment, try on Ditto and perform your first peer-to-peer sync.
Intended to get you oriented, this article provides a streamlined process for integrating sync functionality within your app.
If you prefer building and exploring through a chat app, and so on, see Example Projects Overview.
Integrate the Ditto SDK in your codebase, set up authentication, and then start syncing offline:
From the top-most scope of your app's codebase, add the following to set up authentication and start syncing offline.
Replace YOUR_APP_ID and YOUR_PLAYGROUND_TOKEN with your access credentials available from the portal.
To register a new sync subscription in your app. For example, the following snippet demonstrates how to establish a subscription to sync updates to documents in the cars collection with a field of color set to the value blue:
Sync subscriptions also support argument injection using the :argument syntax in DQL:
Retrieve active sync subscriptions by calling the subscriptions method on the ditto.sync namespace:
You can check if a sync subscription is canceled by using the isCancelled field on the subscription object: