DataSyncEntity

A handle for subscribing to DataSync realtime events about an Entity by its ref/id.

A DataSync handle is a channel filter on the ref, not a type filter: subscribing to dataSyncEntity(id) delivers the mix of events routed to that ref-channel. Branch on the sealed com.pubnub.api.models.consumer.pubsub.datasync.PNDataSyncEventResult.extractedMessage.

PAM: because subscribing is a plain PubSub read of the ref-channel, an authorized client needs a channel read grant on the resolved ref-channel name. Use com.pubnub.api.java.models.consumer.access_manager.v3.DataSyncGrant.subscribe (subscribe(id) for the default projection, subscribe(id, projection) for a non-default one) or com.pubnub.api.java.models.consumer.access_manager.v3.DataSyncGrant.subscribePattern for many refs. This is separate from the DataSync CRUD permission on the entity record (com.pubnub.api.java.models.consumer.access_manager.v3.DataSyncGrant.entity): the record grant does not authorize the subscribe, and the subscribe grant does not authorize record CRUD.

The two projection parameters differ: on entity(..) it sets the REST read view (meta.pn-projections); on subscribe(..) it only selects the ref-channel name (__{projection}__{id}) and adds nothing to the meta. To read through and subscribe to a projection, grant both:

DataSyncGrant.entity("capy-001").get().projection("admin");
DataSyncGrant.subscribe("capy-001", "admin");

Use the com.pubnub.api.java.PubNub.dataSyncEntity factory method to create instances of this interface.

Properties

Link copied to clipboard
abstract val id: String

The entity's ref/id.

Functions

Link copied to clipboard
abstract fun subscription(): Subscription
abstract override fun subscription(options: SubscriptionOptions): Subscription

Returns a Subscription to this entity's default-projection ref-channel.

abstract fun subscription(projection: String): Subscription
abstract fun subscription(projection: String, options: SubscriptionOptions = EmptyOptions): Subscription

Returns a Subscription to this entity's events for the given projection.