Datasync
Types related to the Datasync service.
-
A value to filter the children affected by a node subscription.
This type is used by the
DatasyncNode.subscribe(to:childrenConstraint:stores:file:line:queue:onEvent:onCompletion:)
method.The children constraint defines a kind of visibility window. For the subscription to which it is applied, children that enter in the window are seen as if they were added, and children that leave the window are seen as if they were removed.
See moreDeclaration
Swift
public enum DatasyncChildrenConstraint : Equatable, CustomStringConvertible
-
A value representing the policy to apply to a completed subscription.
Whatever the policy, when a subscription is completed, its callback stops to be called. If the subscription is held by a view that is closed, the subscription must be completed as soon as its event callback uses the view.
The SDK can keep the data available in the cache. This makes it possible to obtain the last got value in case of a subsequent read when there is no network connection at that time.
It can also continue to silently maintain up-to-date the cache for that subscription. This can be useful when the subscription is intended to be redone later, perhaps while being offline. In this case, it may be preferable to present the user with the most recent value of the data, including a post-subscription value. However, this continues to consume network bandwidth as data continues to be transferred.
See moreDeclaration
Swift
public enum DatasyncCompletedSubscriptionPolicy
-
A value representing an event of the
DatasyncService
.When the the
See moreDatasyncEventType.child(addition:change:removal:acknowledgement:)
type was specified for the subscription, eachDatasyncEvent
instance corresponds to exactly one addition or one change or one removal or one acknowledgement. When there are several additions and/or changes and/or removals and/or acknowledgements for the same node, severalDatasyncEvent
instances are sent.Declaration
Swift
public struct DatasyncEvent : CustomStringConvertible, CustomDebugStringConvertible
-
A value representing the type of an event for a node.
This type is used to indicate:
- the type of events to subscribe to using the
DatasyncNode.subscribe(to:childrenConstraint:stores:file:line:queue:onEvent:onCompletion:)
method, - the type of a received event by the
DatasyncEvent.eventType
property.
Declaration
Swift
public enum DatasyncEventType : Equatable, CustomStringConvertible
- the type of events to subscribe to using the
-
An object that creates references to database nodes and stores event subscriptions.
The
DatasyncManager.node(for:)
method or the equivalent(_:_:)
operator create aDatasyncNode
instance, which is a reference to a database node.When such a node reference, created from a given manager instance, subscribes to an event with the
DatasyncNode.subscribe(to:childrenConstraint:stores:file:line:queue:onEvent:onCompletion:)
method, setting thestores
parameter totrue
(which is its default value), the returned subscription is stored by that manager. When the manager instance is deinitialized, it implicitly cancels all those stored event subscriptions automatically, including subscriptions that have other references. It is also possible to explicitly cancel an event subscription by calling theDatasyncSubscription.cancel()
method manually.An implicit cancellation and an explicit cancellation do not have the same effect when
DatasyncManager.defaultCompletedSubscriptionPolicy
isDatasyncCompletedSubscriptionPolicy.keepUpdatingDataWhenImplicit
.Managers are designed to be used as properties in view controllers, in order to bind their respective lifecycles. The view controller uses this manager to create node references and subscribe to events. Thanks to ARC (automatic reference counting), the subscriptions are automatically cancelled when the view controller is unloaded.
See moreDeclaration
Swift
public final class DatasyncManager : CustomDebugStringConvertible
extension DatasyncManager: WebcomCombinable
-
An object that represents a reference to a database node.
By abuse of language, the node reference is sometimes assimilate with the referred node itself. This does not usually preclude understanding. Just keep in mind that there may be several references for the same database node.
From a theoretical point of view, all nodes always exist: the concept on existence is a nonsense. From a practical point of view, we often consider that a node exists when its value is not
null
(the JSONnull
value, not to be confused with the Swiftnil
keyword).Instances are typically created using:
- the
DatasyncManager.node(for:)
method or the equivalent(_:_:)
operator of aDatasyncManager
instance, - the
DatasyncNode.relativeNode(for:)
method of anotherDatasyncNode
instance or, - the
DatasyncNode.push(_:queue:then:)
method or the equivalentDatasyncNode.+=(_:_:)
operator of anotherDatasyncNode
instance, - the
DatasyncEvent.node
property of aDatasyncEvent
value.
A node reference always belongs to the
See moreDatasyncManager
from which it was created. A node reference created from another node reference belongs to the same manager as the latter. A node reference obtained from an event belongs to the same manager as the node that subscribes to that event. Furthermore, thisDatasyncManager
instance derives from aWebcomApplication
instance.Declaration
Swift
public final class DatasyncNode : Hashable, CustomStringConvertible
extension DatasyncNode: WebcomCombinable
- the
-
Declaration
Swift
extension DatasyncNode?
-
An object representing the Datasync service of a
WebcomApplication
instance. This service consists of a real-time database with a tree-like data model (equivalent to a JSON object).To get an object of this type, use the
WebcomApplication.datasyncService
property of aWebcomApplication
instance. There is only one instance of this class for eachWebcomApplication
instance.A web socket with the back-end is opened for each instance.
See moreDeclaration
Swift
public final class DatasyncService : WebcomService
extension DatasyncService: WebcomCombinable
-
A value used to represent the state of the web socket opened by a
See moreDatasyncService
instance.Declaration
Swift
public struct DatasyncState : Codable, Equatable, CustomStringConvertible, CustomDebugStringConvertible
-
An object representing a subscription to Datasync events.
Instances are created by the
DatasyncNode.subscribe(to:childrenConstraint:stores:file:line:queue:onEvent:onCompletion:)
method.A subscription is cancelled:
- explicitly using the
DatasyncSubscription.cancel()
method, - implicitly when it is stored in a
DatasyncManager
which is deinitialized, including when it has other references, - implicitly when it is deinitialized.
Declaration
Swift
public final class DatasyncSubscription : Hashable, CustomStringConvertible, CustomDebugStringConvertible
- explicitly using the
-
A value that represents how a subscription completed.
See moreDeclaration
Swift
@frozen public enum DatasyncSubscriptionCompletion : Equatable, CustomStringConvertible
-
A value indicating the time at which to perform an operation
See moreDeclaration
Swift
public enum DatasyncTime : Equatable
-
A namespace for stuff related to transactions.
This enumeration does not contain any
See morecase
, since it is only used as a namespace.Declaration
Swift
public enum DatasyncTransaction
-
The value of a node.
See moreDeclaration
Swift
public struct DatasyncValue : WebcomValuable, CustomStringConvertible