SyncDocument

interface SyncDocument

SyncDocument is an arbitrary JSON value.

You can set, get and modify this value.

To obtain an instance of a SyncDocument use SyncClient.documents

Types

Link copied to clipboard
interface Events

Properties

Link copied to clipboard
abstract val data: <Error class: unknown class>

Value of the document as a JSON object.

Link copied to clipboard
abstract val dateCreated: <Error class: unknown class>

A date when this SyncDocument was created.

Link copied to clipboard
abstract val dateExpires: <Error class: unknown class>?

A date this SyncDocument will expire, null means will not expire.

Link copied to clipboard
abstract val dateUpdated: <Error class: unknown class>

A date when this SyncDocument was last updated.

Link copied to clipboard

Provides scope of Flows objects to get notified about events.

Link copied to clipboard

true when this SyncDocument is offline and doesn't receive updates from backend, false otherwise.

Link copied to clipboard
abstract val isRemoved: Boolean

true when this SyncDocument has been removed on the backend, false otherwise.

Link copied to clipboard
abstract val sid: EntitySid

An immutable system-assigned identifier of this SyncDocument.

Link copied to clipboard

Current subscription state.

Link copied to clipboard
abstract val uniqueName: String?

An optional unique name for this document, assigned at creation time.

Functions

Link copied to clipboard
abstract fun close()

Close this SyncDocument.

Link copied to clipboard
inline fun <T : Any> SyncDocument.data(): T

Deserializes the SyncDocument.data into a value of type T using a deserializer retrieved from reified type parameter.

Link copied to clipboard
abstract suspend fun mutateData(mutator: suspend (<Error class: unknown class>) -> <Error class: unknown class>?)

Mutate value of the SyncDocument using provided Mutator function.

Link copied to clipboard
inline suspend fun <T : Any> SyncDocument.mutateData(crossinline mutator: suspend (currentData: T) -> T?)

Serializes the value returned by Mutator function into an equivalent JsonObject using a serializer retrieved from reified type parameter and uses the JsonObject to mutate value of the SyncDocument

Link copied to clipboard
abstract suspend fun mutateDataWithTtl(ttl: <Error class: unknown class>, mutator: suspend (<Error class: unknown class>) -> <Error class: unknown class>?)

Mutate value of the SyncDocument using provided Mutator function.

Link copied to clipboard
inline suspend fun <T : Any> SyncDocument.mutateDataWithTtl(ttl: <Error class: unknown class>, crossinline mutator: suspend (currentData: T) -> T?)

Serializes the value returned by Mutator function into an equivalent JsonObject using a serializer retrieved from reified type parameter and uses the JsonObject to mutate value of the SyncDocument

Link copied to clipboard
abstract suspend fun removeDocument()

Remove this SyncDocument.

Link copied to clipboard
abstract suspend fun setData(data: <Error class: unknown class>)

Set value of the SyncDocument as a JSON object.

Link copied to clipboard
inline suspend fun <T : Any> SyncDocument.setData(data: T)

Serializes the given value into an equivalent JsonObject using a serializer retrieved from reified type parameter and set it as value of the SyncDocument.

Link copied to clipboard
abstract suspend fun setDataWithTtl(data: <Error class: unknown class>, ttl: <Error class: unknown class>)

Set value of the SyncDocument as a JSON object.

Link copied to clipboard
inline suspend fun <T : Any> SyncDocument.setDataWithTtl(data: T, ttl: <Error class: unknown class>)

Serializes the given value into an equivalent JsonObject using a serializer retrieved from reified type parameter and set it as value of the SyncDocument.

Link copied to clipboard
abstract suspend fun setTtl(ttl: <Error class: unknown class>)

Set time to live for this SyncDocument.

Link copied to clipboard
inline fun <R> SyncDocument.use(block: (SyncDocument) -> R): R

Executes the given block function on SyncDocument and then closes it down correctly whether an exception is thrown or not.