SyncSubscriptionSet
@frozen
public struct SyncSubscriptionSet
extension SyncSubscriptionSet: Sequence
SyncSubscriptionSet is a collection of SyncSubscriptions. This is the entry point
for adding and removing SyncSubscriptions.
-
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.
Declaration
Swift
public func update(_ block: (() -> Void), onComplete: (@Sendable (Error?) -> Void)? = nil)Parameters
blockThe block containing the subscriptions transactions to perform.
onCompleteThe 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
namedThe 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 : RealmSwiftObjectParameters
typeThe type of the object to be queried.
whereA 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 : RealmSwiftObjectParameters
typeThe type of the object to be queried.
whereA 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 : RealmSwiftObjectParameters
typeThe type of the object to be queried.
whereA 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 : RealmSwiftObjectParameters
subscriptionsThe 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
Parameters
typeThe type of the object to be removed.
toA 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 : RealmSwiftObjectParameters
typeThe type of the object to be removed.
predicateFormatA 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 : RealmSwiftObjectParameters
typeThe type of the object to be removed.
predicateThe 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
subscriptionThe 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
namedThe 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 : RealmSwiftObjectParameters
typeThe type of the objects to be removed.
-
Returns the subscription at the given
position.Declaration
Swift
public subscript(position: Int) -> SyncSubscription? { get }Parameters
positionThe index for the resulting subscription.
-
Returns the first object in the SyncSubscription list, or
nilif the subscriptions are empty.Declaration
Swift
public var first: SyncSubscription? { get } -
Returns the last object in the SyncSubscription list, or
nilif the subscriptions are empty.Declaration
Swift
public var last: SyncSubscription? { get }
-
Returns a
SyncSubscriptionSetIteratorthat yields successive elements in the subscription collection.Declaration
Swift
public func makeIterator() -> SyncSubscriptionSetIterator -
update(_:Asynchronous) Creates and commits a transaction, updating the subscription set, this will continue when the server acknowledge and all the data associated with this collection of subscriptions is synced.
Throws
An
NSErrorif the subscription set state changes to an error state or there is and error while committing any changes to the subscriptions.Declaration
Swift
@MainActor public func update(_ block: (() -> Void)) async throwsParameters
blockThe block containing the subscriptions transactions to perform.
-
Creates and commit a transaction, updating the subscription set, this will return success when the server acknowledge and all the data associated with this collection of subscriptions is synced.
Declaration
Swift
public func updateSubscriptions(_ block: @escaping (() -> Void)) -> Future<Void, Error>Parameters
blockThe block containing the subscriptions transactions to perform.
Return Value
A publisher that eventually returns
Result.successorError.
View on GitHub
Install in Dash