ViewModelInstance

A view model instance for data binding which has properties that can be set and observed.

The instance must be bound to a state machine for its values to take effect. This is done by passing it to Rive.

Parameters

instanceHandle

The handle to the view model instance on the command server.

riveWorker

The Rive worker that owns the view model instance.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun appendToList(propertyPath: String, item: ViewModelInstance)

Appends an item to the end of a list property.

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun fireTrigger(propertyPath: String)

Fires a trigger on this view model instance.

Link copied to clipboard
fun getBooleanFlow(propertyPath: String): Flow<Boolean>

Creates or retrieves from cache a boolean property, represented as a cold Flow.

Link copied to clipboard
fun getColorFlow(propertyPath: String): Flow<Int>

Creates or retrieves from cache a color property, represented as a cold Flow. Colors are represented as AARRGGBB integers, and this flow will emit the integer value of the color.

Link copied to clipboard
fun getEnumFlow(propertyPath: String): Flow<String>

Creates or retrieves from cache an enum property, represented as a cold Flow. Enums are represented as strings, and this flow will emit the string value of the enum.

Link copied to clipboard
suspend fun getListSize(propertyPath: String): Int
Link copied to clipboard
fun getNumberFlow(propertyPath: String): Flow<Float>

Creates or retrieves from cache a number property, represented as a cold Flow.

Link copied to clipboard
fun getStringFlow(propertyPath: String): Flow<String>

Creates or retrieves from cache a string property, represented as a cold Flow.

Link copied to clipboard
fun getTriggerFlow(propertyPath: String): Flow<Unit>

Creates or retrieves from cache a trigger property, represented as a cold Flow. Triggers emit Unit as the value, which simply indicates that the trigger has been fired.

Link copied to clipboard
fun insertToListAtIndex(propertyPath: String, index: Int, item: ViewModelInstance)

Inserts an item into a list property at the specified index.

Link copied to clipboard
fun removeFromList(propertyPath: String, item: ViewModelInstance)

Removes an item from a list property.

Link copied to clipboard
fun removeFromListAtIndex(propertyPath: String, index: Int)

Removes an item from a list property at the specified index.

Link copied to clipboard
fun setArtboard(propertyPath: String, artboard: Artboard?)

Assigns the given artboard to the bindable artboard property on this view model instance, or clears the property if artboard is null.

Link copied to clipboard
fun setBoolean(propertyPath: String, value: Boolean)

Sets a boolean property on this view model instance.

Link copied to clipboard
fun setColor(propertyPath: String, @ColorInt value: Int)

Sets a color property on this view model instance. Colors are represented as AARRGGBB integers.

Link copied to clipboard
fun setEnum(propertyPath: String, value: String)

Sets an enum property on this view model instance. Enums are represented as strings.

Link copied to clipboard
fun setImage(propertyPath: String, image: ImageAsset)

Assigns the given image to the image property on this view model instance.

Link copied to clipboard
fun setNumber(propertyPath: String, value: Float)

Sets a number property on this view model instance.

Link copied to clipboard
fun setString(propertyPath: String, value: String)

Sets a string property on this view model instance.

Link copied to clipboard
fun setViewModelInstance(propertyPath: String, instance: ViewModelInstance)

Assigns the given view model instance to the nested view model property on this view model instance.

Link copied to clipboard
fun swapListItems(propertyPath: String, indexA: Int, indexB: Int)

Swaps two items in a list property by their indices.