DittoSync
public class DittoSync
Provides access to sync related functionality of Ditto.
-
Starts the network transports. Ditto will connect to other devices.
By default Ditto will enable all peer-to-peer transport types. On Apple devices, this means BluetoothLE, WiFi/LAN, and AWDL. The default network configuration can be modified with
updateTransportConfig()or replaced via thetransportConfigproperty.Performance of initial sync when bootstrapping a new peer can be improved by calling
disableSyncWithV3()before callingstart(). Only do this when all peers in the mesh are known to be running Ditto v4 or higher.Throws
DittoError.Declaration
Swift
public func start() throws -
Stops all network transports.
You may continue to use the Ditto store locally but no data will sync to or from other devices.
Declaration
Swift
public func stop()
-
Returns all currently active sync subscriptions.
Declaration
Swift
public private(set) var subscriptions: Set<DittoSyncSubscription> { get } -
Installs and returns a sync subscription for a query, configuring Ditto to receive updates from other peers for documents matching that query. The passed in query must be a
SELECTquery, otherwise a store error withqueryNotSupportedreason is thrown.Throws
DittoError>.storeError(.queryInvalid)ifquerystring is not valid DQL.Throws
DittoError>.storeError(.queryArgumentsInvalid)ifargumentsdictionary is not valid (contains unsupported types).Throws
DittoError>.storeError(.queryNotSupported)if query is not aSELECTquery.Throws
May throw other
DittoErrors.Declaration
Swift
@discardableResult public func registerSubscription( query: String, arguments: Dictionary<String, Any?>? = nil ) throws -> DittoSyncSubscriptionReturn Value
An active
SyncSubscriptionfor the passed in query and arguments. You’ll have to keep it to be able to cancel the sync subscription. Otherwise it will remain active until the owningDittoobject goes out of scope.