DittoSync

public class DittoSync

Provides access to sync related functionality of Ditto.

Managing Sync Subscriptions

  • 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 SELECT query, otherwise a store error with queryNotSupported reason is thrown.

    Throws

    DittoSwiftError > .storeError(.queryInvalid) if query string is not valid DQL.

    Throws

    DittoSwiftError > .storeError(.queryArgumentsInvalid) if arguments dictionary is not valid (contains unsupported types).

    Throws

    DittoSwiftError > .storeError(.queryNotSupported) if query is not a SELECT query.

    Throws

    May throw other DittoSwiftErrors.

    Declaration

    Swift

    @discardableResult
    public func registerSubscription(
        query: String,
        arguments: Dictionary<String, Any?>? = nil
    ) throws -> DittoSyncSubscription

    Return Value

    An active SyncSubscription for 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 owning Ditto object goes out of scope.