SyncMap

interface SyncMap

SyncMap is a key-value store with Strings as keys and Item objects as values.

You can add, remove and modify values associated with the keys.

To obtain an instance of a SyncMap use SyncClient.maps

Types

Link copied to clipboard
interface Events
Link copied to clipboard
data class Item(val key: String, val data: <Error class: unknown class>, val dateCreated: <Error class: unknown class>, val dateUpdated: <Error class: unknown class>, val dateExpires: <Error class: unknown class>?)

Represents a value associated with each key in SyncMap.

Properties

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

A date when this SyncMap was created.

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

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

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

A date when this SyncMap was last updated.

Link copied to clipboard
abstract val events: SyncMap.Events

Provides scope of Flows objects to get notified about events.

Link copied to clipboard

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

Link copied to clipboard
abstract val isRemoved: Boolean

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

Link copied to clipboard
abstract val sid: EntitySid

An immutable system-assigned identifier of this SyncMap.

Link copied to clipboard

Current subscription state.

Link copied to clipboard
abstract val uniqueName: String?

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

Functions

Link copied to clipboard
abstract fun close()

Close this SyncMap.

Link copied to clipboard
abstract suspend fun getItem(itemKey: String, useCache: Boolean = true): SyncMap.Item?

Retrieve Item from the SyncMap.

Link copied to clipboard
open operator fun iterator(): SyncIterator<SyncMap.Item>
Link copied to clipboard
abstract suspend fun mutateItem(itemKey: String, mutator: suspend (<Error class: unknown class>?) -> <Error class: unknown class>?): SyncMap.Item

Mutate value of the Item using provided Mutator function.

Link copied to clipboard
inline suspend fun <T : Any> SyncMap.mutateItem(itemKey: String, crossinline mutator: suspend (currentData: T?) -> T?): SyncMap.Item

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 SyncMap.Item

Link copied to clipboard
abstract suspend fun mutateItemWithTtl(itemKey: String, ttl: <Error class: unknown class>, mutator: suspend (<Error class: unknown class>?) -> <Error class: unknown class>?): SyncMap.Item

Mutate value of the Item using provided Mutator function and set time to live for the Item.

Link copied to clipboard
inline suspend fun <T : Any> SyncMap.mutateItemWithTtl(itemKey: String, ttl: <Error class: unknown class>, crossinline mutator: suspend (currentData: T?) -> T?): SyncMap.Item

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 SyncMap.Item

Link copied to clipboard
abstract fun queryItems(startKey: String? = null, includeStartKey: Boolean = true, queryOrder: <Error class: unknown class> = QueryOrder.Ascending, pageSize: Int = kDefaultPageSize, useCache: Boolean = true): SyncIterator<SyncMap.Item>

Retrieve items from the SyncMap.

Link copied to clipboard
abstract suspend fun removeItem(itemKey: String)

Remove Item from the SyncMap.

Link copied to clipboard
abstract suspend fun removeMap()

Remove this SyncMap.

Link copied to clipboard
abstract suspend fun setItem(itemKey: String, itemData: <Error class: unknown class>): SyncMap.Item

Set Item in the SyncMap.

Link copied to clipboard
inline suspend fun <T : Any> SyncMap.setItem(itemKey: String, itemData: T): SyncMap.Item

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

Link copied to clipboard
abstract suspend fun setItemWithTtl(itemKey: String, itemData: <Error class: unknown class>, ttl: <Error class: unknown class>): SyncMap.Item

Set Item in the SyncMap.

Link copied to clipboard
inline suspend fun <T : Any> SyncMap.setItemWithTtl(itemKey: String, itemData: T, ttl: <Error class: unknown class>): SyncMap.Item

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

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

Set time to live for this SyncMap.

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

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