SyncSubscriptionSet

@frozen
public struct SyncSubscriptionSet
extension SyncSubscriptionSet: Sequence

SyncSubscriptionSet is a collection of SyncSubscriptions. This is the entry point for adding and removing SyncSubscriptions.

Initializers

  • The number of subscriptions in the subscription set.

    Declaration

    Swift

    public var count: Int { get }
  • Synchronously performs any transactions (add/remove/update) to the subscription set within the block. This will not wait for the server to acknowledge and see all the data associated with this collection of subscriptions, and will return after committing the subscription transactions.

    Declaration

    Swift

    public func write(_ block: (() -> Void), onComplete: ((Error?) -> Void)? = nil)

    Parameters

    block

    The block containing the subscriptions transactions to perform.

    onComplete

    The block called upon synchronization of subscriptions to the server. Otherwise an Errordescribing what went wrong will be returned by the block

  • Returns the current state for the subscription set.

    Declaration

    Swift

    public var state: SyncSubscriptionState { get }
  • Returns a subscription by the specified name.

    Declaration

    Swift

    public func first(named: String) -> SyncSubscription?

    Parameters

    named

    The name of the subscription searching for.

    Return Value

    A subscription for the given name.

  • Returns a subscription by the specified query.

    Declaration

    Swift

    public func first<T>(ofType type: T.Type, where query: @escaping (Query<T>) -> Query<Bool>) -> SyncSubscription? where T : RealmSwiftObject

    Parameters

    type

    The type of the object to be queried.

    where

    A query builder that produces a subscription which can be used to search the subscription by query and/or name.

    Return Value

    A query builder that produces a subscription which can used to search for the subscription.

  • Returns a subscription by the specified query.

    Declaration

    Swift

    public func first<T>(ofType type: T.Type, where predicateFormat: String, _ args: Any...) -> SyncSubscription? where T : RealmSwiftObject

    Parameters

    type

    The type of the object to be queried.

    where

    A query builder that produces a subscription which can be used to search the subscription by query and/or name.

    Return Value

    A query builder that produces a subscription which can used to search for the subscription.

  • Returns a subscription by the specified query.

    Declaration

    Swift

    public func first<T>(ofType type: T.Type, where predicate: NSPredicate) -> SyncSubscription? where T : RealmSwiftObject

    Parameters

    type

    The type of the object to be queried.

    where

    A query builder that produces a subscription which can be used to search the subscription by query and/or name.

    Return Value

    A query builder that produces a subscription which can used to search for the subscription.

  • Appends one or several subscriptions to the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Swift

    public func append<T>(_ subscriptions: QuerySubscription<T>...) where T : RealmSwiftObject

    Parameters

    subscriptions

    The subscriptions to be added to the subscription set.

  • Removes a subscription with the specified query.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Swift

    public func remove<T>(ofType type: T.Type, _ query: @escaping (Query<T>) -> Query<Bool>) where T : RealmSwiftObject

    Parameters

    type

    The type of the object to be removed.

    to

    A query for the subscription to be removed from the subscription set.

  • Removes a subscription with the specified query.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Swift

    public func remove<T>(ofType type: T.Type, where predicateFormat: String, _ args: Any...) where T : RealmSwiftObject

    Parameters

    type

    The type of the object to be removed.

    predicateFormat

    A predicate format string, optionally followed by a variable number of arguments, which will be used to identify the subscription to be removed.

  • Removes a subscription with the specified query.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Swift

    public func remove<T>(ofType type: T.Type, where predicate: NSPredicate) where T : RealmSwiftObject

    Parameters

    type

    The type of the object to be removed.

    predicate

    The predicate which will be used to identify the subscription to be removed.

  • Removes one or several subscriptions from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Swift

    public func remove(_ subscriptions: SyncSubscription...)

    Parameters

    subscription

    The subscription to be removed from the subscription set.

  • Removes a subscription with the specified name from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Swift

    public func remove(named: String)

    Parameters

    named

    The name of the subscription to be removed from the subscription set.

  • Removes all subscriptions from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Warning

    Removing all subscriptions will result in an error if no new subscription is added. Server should acknowledge at least one subscription.

    Declaration

    Swift

    public func removeAll()
  • Removes zero or none subscriptions of the given type from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Swift

    public func removeAll<T>(ofType type: T.Type) where T : RealmSwiftObject

    Parameters

    type

    The type of the objects to be removed.

Subscription Retrieval

  • Returns the subscription at the given position.

    Declaration

    Swift

    public subscript(position: Int) -> SyncSubscription? { get }

    Parameters

    position

    The index for the resulting subscription.

  • Returns the first object in the SyncSubscription list, or nil if the subscriptions are empty.

    Declaration

    Swift

    public var first: SyncSubscription? { get }
  • Returns the last object in the SyncSubscription list, or nil if the subscriptions are empty.

    Declaration

    Swift

    public var last: SyncSubscription? { get }

Sequence Support

  • Returns a SyncSubscriptionSetIterator that yields successive elements in the subscription collection.

    Declaration

    Swift

    public func makeIterator() -> SyncSubscriptionSetIterator
  • write(_:) Asynchronous

    Asynchronously creates and commit a write transaction and updates the subscription set, this will not wait for the server to acknowledge and see all the data associated with this collection of subscription.

    Throws

    An NSError if the transaction could not be completed successfully. If block throws, the function throws the propagated ErrorType instead.

    Declaration

    Swift

    @MainActor
    public func write(_ block: (() -> Void)) async throws

    Parameters

    block

    The block containing the subscriptions transactions to perform.