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.

fun cancelSubscriptionsThroughPushNotification(cipher: CryptoMethod = CryptoMethod.None, callback: WebcomDoneCallback? = null)

Cancel all subscriptions previously subscribed through the mobile push notification channel of the user mobile device (with the subscribeThroughPushNotification method).

cancelSubscriptionsThroughWebhook
Link copied to clipboard
fun cancelSubscriptionsThroughWebhook(identifier: String, context: String, callback: WebcomDoneCallback? = null)

Cancel all subscriptions previously subscribed through the webhook channel (with the subscribeThroughWebhook method).

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(constraint: Constraint = Constraint.None, callback: WebcomResultCallback<DatasyncValue>)

Reads asynchronously the data at this data node, with a possible constraint.

getFromCache
Link copied to clipboard
fun getFromCache(): DatasyncValue

Reads the data stored in the local cache at this data node. This method returns synchronously and doesn't send any request to the Webcom back end.

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: (DatasyncValue) -> 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 <T : SubscribableEvent> subscribe(type: KClass<T>, constraint: Constraint = Constraint.None, options: SubscriptionOptions = SubscriptionOptions(), callback: (Notification<T>) -> Unit): Subscription

Subscribes to a type of event with a given constraint on this data node and sends notifications to a callback function.

subscribeThroughPushNotification
Link copied to clipboard
fun <T : SubscribableEvent> subscribeThroughPushNotification(type: KClass<T>, 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 send notifications through the mobile push notification channel of the user mobile device.

fun <T : SubscribableEvent> subscribeThroughPushNotification(type: KClass<T>, 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 send notifications through the mobile push notification channel of the user mobile device.

subscribeThroughWebhook
Link copied to clipboard
fun <T : SubscribableEvent> subscribeThroughWebhook(type: KClass<T>, 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 <T : SubscribableEvent> subscribeThroughWebhook(type: KClass<T>, 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.

timestamp
Link copied to clipboard
val timestamp: Date

Gets the timestamp encoded within the key of this DatasyncNode, when it has been generated using the createChild or push methods.