DatasyncNode

class DatasyncNode(manager: DatasyncManager, val path: String) : 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.

Constructors

Link copied to clipboard
fun DatasyncNode(manager: DatasyncManager, path: String)

Functions

Link copied to clipboard
fun cancelNextDisconnectionAction(callback: WebcomDoneCallback? = null)

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).

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).

Link copied to clipboard
fun clear(at: DatasyncTime = DatasyncTime.Now, callback: WebcomDoneCallback? = null)

Clears data at this data node asynchronously.

Link copied to clipboard
fun createChild(): DatasyncNode

Returns a child of this data node with a unique key.

Link copied to clipboard
operator fun div(path: String): DatasyncNode

Shortcut for relativeNode.

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.

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.

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.

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.

Link copied to clipboard
operator fun plusAssign(value: Any?)

Shortcut for 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.

Link copied to clipboard
fun relativeNode(relativePath: String): DatasyncNode

Returns the data done specified by a path relatively to the data node represented by this DatasyncNode instance.

Link copied to clipboard
fun runTransaction(transaction: (DatasyncValue) -> TransactionOperation, callback: WebcomResultCallback<TransactionResult>? = null)

Performs an atomic write operation (or transaction) on this data node.

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.

Link copied to clipboard
fun <T : SubscribableEvent> subscribe(    type: KClass<T>,     constraint: Constraint = Constraint.None,     options: SubscriptionOptions = SubscriptionOptions()): LiveData<Notification<T>>

Same as Subscriber.subscribe, but use a LiveData object rather than callback to notify events to the user

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.

Link copied to clipboard
@RequiresApi(value = 26)
fun <T : SubscribableEvent> subscribeThroughPushNotification(    type: KClass<T>,     duration: Duration,     cipher: CryptoMethod = CryptoMethod.None,     includesRevocation: Boolean = true,     callback: WebcomResultCallback<LongTermSubscription>)

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<LongTermSubscription>)

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.

Link copied to clipboard
@RequiresApi(value = 26)
fun <T : SubscribableEvent> subscribeThroughWebhook(    type: KClass<T>,     identifier: String,     context: String,     duration: Duration,     includesRevocation: Boolean = true,     callback: WebcomResultCallback<LongTermSubscription>)

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<LongTermSubscription>)

Subscribes to a type of event on this data node until a given expirationDate and send notifications to a webhook.

Properties

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.

Link copied to clipboard
val parent: DatasyncNode?

Gets the parent data node of this DatasyncNode instance.

Link copied to clipboard
val path: String

The path of this data node within the Webcom application.

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.