subscribe

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.

If options has SubscriptionOptions.includesAcknowledgements set to true, the callback function is additionally notified when the data node is acknowledged by the back end (without other value change).

If the callback function receives a Canceled or a DatasyncEvent.Revoked, it will no longer be called because the subscription is over. The received notifications are of the type T of the subscribed events.

The resulting Subscription can be deliberately canceled by invoking its Subscription.cancel method.