DatasyncTransaction
public enum DatasyncTransaction
A namespace for stuff related to transactions.
This enumeration does not contain any case, since it is only used as a namespace.
-
A value representing an operation to be performed by a transaction on a given node.
See moreDeclaration
Swift
public enum Operation -
A type representing a function to run on a node in a transactional way.
Declaration
Swift
public typealias Function = (_ value: DatasyncValue) -> OperationParameters
valueThe current value of the node.
Return Value
An operation to be performed on the node value.
-
A value representing the status of a terminated transaction.
See moreDeclaration
Swift
@frozen public enum Status : Equatable -
A value representing the result of running a transaction on a given node.
See moreDeclaration
Swift
public struct Result
-
Returns a transaction function that toggle the boolean value of the node.
When the node does not exist (in other words, when its initial value is
null), thedefaultValueis set.When the node exists and its initial value is not a boolean, the transaction is aborted.
When the node has initially the
true(respectivelyfalse) value, it is set tofalse(respectivelytrue).Declaration
Swift
public static func toggle(defaultValue: Bool = false) -> FunctionParameters
defaultValueThe final value of the node when it does not exist.
Return Value
A transaction that toggle the value of the node when it is a boolean.
-
Returns a transaction function that toggle the boolean value of the node.
When the node does not exist (in other words, when its initial value is
null), thepingvalue is set.When the node exists and its initial value is not decodable neither to
pingnor topong, the transaction is aborted.When the node initial value is decodable to
ping(respectivelypong), it is set topong(respectivelyping).Declaration
Swift
public static func toggle<T>(between ping: T, and pong: T) -> Function where T : Decodable, T : Encodable, T : EquatableParameters
pingThe first of the two values to toggle between.
pongThe second of the two values to toggle between.
Return Value
A transaction that toggle the value of the node between
pingandpong. -
Returns a transaction that sets the value of the node when it does not exist.
When the node does not exist (in other words, when its initial value is
null), thejsonvalue is set. Otherwise the transaction is aborted.Declaration
Swift
public static func writeIfNone(_ raw: WebcomMarkers.Raw, _ json: Any?) -> FunctionParameters
rawUse the
.rawvalue to disambiguate with thewriteIfNone(_:)overload that takes anEncodableparameter.jsonThe value to set when the node does not exist.
Return Value
A transaction that sets
jsonto the node when it does not exist. -
Returns a transaction that sets the value of the node when it does not exist.
When the node does not exist (in other words, when its initial value is
null), thevaluevalue is set. Otherwise the transaction is aborted.Declaration
Swift
public static func writeIfNone(_ value: some Encodable) -> FunctionParameters
valueThe value to set when the node does not exist. It will be encoded to JSON before being sent to the back-end, using the
WebcomApplication.jsonDecoderof theWebcomApplicationfrom which the node derives.Return Value
A transaction that sets
valueto the node when it does not exist.