Other Type Aliases

The following type aliases are available globally.

  • A closure type that handles authentication expiration events for Ditto.

    Important

    This API is in preview and provides a modern, Swift-native alternative to the phased out DittoAuthenticationDelegate protocol in v5.

    This handler is called when the authentication for a Ditto instance has or is about to expire, or if authentication has not yet occurred. It provides the relevant Ditto instance and the time interval (in seconds) until expiration. You can use this to login or to perform other necessary actions before authentication expires.

    Important

    When using server connections (server(url:)), you must set an expiration handler via expirationHandler. Otherwise start() will throw DittoSwiftError/authenticationError(_:) with AuthenticationErrorReason/expirationHandlerMissing(message:) reason.

    Declaration

    Swift

    public typealias DittoAuthenticationExpirationHandler =
        (_ ditto: Ditto, _ timeUntilExpiration: TimeInterval) async -> Void

    Parameters

    ditto

    The Ditto instance whose authentication is expiring.

    timeUntilExpiration

    The time interval, in seconds, until authentication expires.

  • A handler for connection requests from other peers.

    Set a DittoConnectionRequestHandler on DittoPresence.connectionRequestHandler() to allow or deny connection requests from other peers.

    Declaration

    Swift

    public typealias DittoConnectionRequestHandler = (_ connectionRequest: DittoConnectionRequest) async -> DittoConnectionRequestAuthorization

    Parameters

    connectionRequest

    Contains information about the remote peer that can be used to make an authorization decision.

    Return Value

    .allow if the request should be authorized, .deny otherwise.

  • Undocumented

    Declaration

    Swift

    public typealias DittoSwiftError = DittoError
  • A closure that tells Ditto the observer’s handler is ready to receive another callback. This is a mechanism for handling backpressure when updates arrive faster than the handler can process them. Ditto pauses further callbacks, but continues to apply changes to the local store. If multiple relevant changes occur while paused, Ditto does not queue a callback for each change. After this closure is invoked, Ditto calls the handler once with the latest result if that result differs from the last result delivered.

    Declaration

    Swift

    public typealias DittoSignalNext = () -> Void
  • A store observation handler is called whenever an active store observer receives a new query result.

    Declaration

    Swift

    public typealias DittoStoreObservationHandler = (_ result: DittoQueryResult) -> Void
  • A store observation handler is called whenever an active store observer receives a new query result.

    Call signalNext() to signal that the handler is ready to receive the next callback from the store observer. See DittoSignalNext for how this mechanism handles backpressure.

    Declaration

    Swift

    public typealias DittoStoreObservationHandlerWithSignalNext = (_ result: DittoQueryResult, _ signalNext: @escaping DittoSignalNext) -> Void