DatasyncNode

class DatasyncNode : Subscriber

Represents a data node within the tree-like data of a Webcom application.

This class provides basic methods to browse, read, write data nodes, as well as subscribe to some events at a data node. Instances of DatasyncNode are built using the DatasyncManager.node method.

Functions

cancelNextDisconnectionAction
Link copied to clipboard
fun cancelNextDisconnectionAction()
Cancels any previous write operation on this data node with the DatasyncTime.AtNextDisconnection policy.
clear
Link copied to clipboard
fun clear(at: DatasyncTime = DatasyncTime.Now, callback: WebcomDoneCallback? = null)
Clears data at this data node asynchronously.
createChild
Link copied to clipboard
fun createChild(): DatasyncNode
Returns a child of this data node with a unique key.
div
Link copied to clipboard
operator fun div(path: String): DatasyncNode
Shortcut for relativeNode.
get
Link copied to clipboard
fun get(callback: WebcomResultCallback<DatasyncValuable>)
Reads the data at this data node asynchronously.
increment
Link copied to clipboard
fun increment(step: Number, startValue: Number = 0, callback: WebcomResultCallback<Number>? = null)
Atomically increments the value at this data node by a given step.
merge
Link copied to clipboard
fun merge(value: Any?, callback: WebcomDoneCallback? = null)
Convenient shortcut for merge(DatasyncTime.Now, value, callback).
fun merge(at: DatasyncTime, value: Any?, callback: WebcomDoneCallback? = null)
Merges some data with the data at this data node asynchronously.
plusAssign
Link copied to clipboard
operator fun plusAssign(value: Any?)
Shortcut for push.
push
Link copied to clipboard
fun push(value: Any?, callback: WebcomResultCallback<String>? = null): DatasyncNode
Creates a child of this data node with a unique key and writes a given value at it.
relativeNode
Link copied to clipboard
fun relativeNode(path: String): DatasyncNode
Returns the data done specified by a path relatively to the data node represented by this DatasyncNode instance.
runTransaction
Link copied to clipboard
fun runTransaction(transaction: (DatasyncValuable) -> TransactionOperation, callback: WebcomResultCallback<TransactionResult>? = null)
Performs an atomic write operation (or transaction) on this data node.
set
Link copied to clipboard
fun set(value: Any?, callback: WebcomDoneCallback? = null)
Convenient shortcut for set(DatasyncTime.Now, value, callback).
fun set(at: DatasyncTime, value: Any?, callback: WebcomDoneCallback? = null)
Writes some data at this data node asynchronously.
subscribe
Link copied to clipboard
fun subscribe(type: Child, constraint: Constraint = Constraint.None, includesAcknowledgements: Boolean = false, callback: WebcomResultCallback<ChildEvent>): Subscription
Subscribes to a Child event with a given constraint on this data node and sends notifications to a callback function.
fun subscribe(type: ValueChanged.WithData, constraint: Constraint = Constraint.None, includesAcknowledgements: Boolean = false, callback: WebcomResultCallback<ValueChangedWithDataEvent>): Subscription
Subscribes to a ValueChanged.WithData event with a given constraint on this data node and sends notifications to a callback function.
fun subscribe(type: ValueChanged.WithoutData, constraint: Constraint = Constraint.None, includesAcknowledgements: Boolean = false, callback: WebcomResultCallback<ValueChangedWithoutDataEvent>): Subscription
Subscribes to a ValueChanged.WithoutData event with a given constraint on this data node and sends notifications to a callback function.
subscribeThroughNotifications
Link copied to clipboard
fun subscribeThroughNotifications(type: Type, duration: Duration, cipher: CryptoMethod = CryptoMethod.None, includesRevocation: Boolean = true, callback: WebcomResultCallback<Subscription>)
Subscribes to a type of event on this data node for a given duration and push notifications to the mobile device.
fun subscribeThroughNotifications(type: Type, expirationDate: Date? = null, cipher: CryptoMethod = CryptoMethod.None, includesRevocation: Boolean = true, callback: WebcomResultCallback<Subscription>)
Subscribes to a type of event on this data node until a given expirationDate and push notifications to the mobile device.
subscribeThroughWebhook
Link copied to clipboard
fun subscribeThroughWebhook(type: Type, identifier: String, context: String, duration: Duration, includesRevocation: Boolean = true, callback: WebcomResultCallback<Subscription>)
Subscribes to a type of event on this data node for a given duration and send notifications to a webhook.
fun subscribeThroughWebhook(type: Type, identifier: String, context: String, expirationDate: Date? = null, includesRevocation: Boolean = true, callback: WebcomResultCallback<Subscription>)
Subscribes to a type of event on this data node until a given expirationDate and send notifications to a webhook.

Properties

key
Link copied to clipboard
val key: String
Gives the key of the data node represented by this DatasyncNode instance, that is, the name of the last segment of its path.
parent
Link copied to clipboard
val parent: DatasyncNode?
Gets the parent data node of this DatasyncNode instance.
path
Link copied to clipboard
val path: String
Gives the path of the data node represented by this DatasyncNode instance.