DatasyncEvent
public struct DatasyncEvent : CustomStringConvertible, CustomDebugStringConvertible
A value representing an event of the DatasyncService
.
When the the DatasyncEventType.child(addition:change:removal:acknowledgement:)
type was specified for the subscription,
each DatasyncEvent
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, several DatasyncEvent
instances are sent.
-
The value of the node to which this event relates.
The returned value depends on
eventType
value:DatasyncEventType.valueChange
orDatasyncEventType.valueAcknowledgement
: The new value of the whole node (that is the node on which the subscription was taken).DatasyncEventType.childRemoval
: The old value of the removed child.DatasyncEventType.childAddition
,DatasyncEventType.childChange
orDatasyncEventType.childAcknowledgement
: The new value of the corresponding child. When the back-end acknowledges the removal of a child, this value is thereforenull
.
Declaration
Swift
public let value: DatasyncValue
-
The key of the sibling child node that precedes the added or changed child in the visibility window.
The order of the keys is defined in the
DatasyncChildrenConstraint
documentation.When the
eventType
isDatasyncEventType.childRemoval
orDatasyncEventType.valueChange
, this property isnil
. When the added of changed child is the first one, this property is alsonil
.Declaration
Swift
public let previousChildKey: String?
-
The subscription that produces this event.
Declaration
Swift
public let subscription: DatasyncSubscription
-
Indicates whether this value wrapped in this event is acknowledged by the back-end.
When this property is
false
, the value is only local. It can be either acknowledged or rejected by the back-end later.Declaration
Swift
public var acked: Bool { get }
-
The atomic type of this event.
This property is useful when an event callback is used for a composite event type.
For example, if:
DatasyncNode.subscribe(to:childrenConstraint:stores:file:line:queue:onEvent:onCompletion:)
was called witheventType
parameter having.child(addition: true, change: true, removal: false, acknowledgement: false)
value (please note thetrue
value for theaddition
associated value),- and this event was triggered by a change in an already existing child,
then this value will be
.child(addition: false, change: true, removal: false, acknowledgement: false)
(please note thefalse
value for theaddition
associated value this time), i.e.DatasyncEventType.childChange
.Declaration
Swift
public var eventType: DatasyncEventType { get }
-
The key of the node to which this event relates.
The returned key depends on
eventType
value:DatasyncEventType.child(addition:change:removal:acknowledgement:)
: The key of the corresponding child.DatasyncEventType.value(change:acknowledgement:)
: The key of the node on which the subscription was taken.
Declaration
Swift
public var key: WebcomKey { get }
-
A reference to the node to which this event relates.
The returned node reference depends on
eventType
value:DatasyncEventType.child(addition:change:removal:acknowledgement:)
: The corresponding child.DatasyncEventType.value(change:acknowledgement:)
: The node on which the subscription was taken.
When the manager of the node whose subscription has emitted this event no longer exists, this property is
nil
. This cannot happen when the subscription is stored by the manager, which corresponds to the default value of thestores
parameter of theDatasyncNode.subscribe(to:childrenConstraint:stores:file:line:queue:onEvent:onCompletion:)
method.Declaration
Swift
public var node: DatasyncNode? { get }
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public var debugDescription: String { get }