Skip to main content
A ViewModel provides access to named properties used for data binding between your application and a Rive file.

Fields

name

The name of the view model. (Coming soon)

Methods

getNumber

Returns the numeric property with the given name, or nil if not found.

getTrigger

Looks up a trigger property by name. Returns a PropertyTrigger.

getString

Looks up a string property by name. Returns a Property<string>, or nil when there is none.

getBoolean

Looks up a boolean property by name. Returns a Property<boolean>, or nil when there is none.

getColor

Looks up a color property by name. Returns a Property<Color>, or nil when there is none.

getList

Looks up a List property by name. Returns a PropertyList.

getViewModel

Looks up a view model property by name. Returns a PropertyViewModel.

getEnum

Looks up an enum by name. Returns a PropertyEnum.

instance

Creates a new instance of the ViewModel. Pass instanceName to specify an existing instance from the file to use as template

getIndex

Returns the view model’s index in the list that holds it, counting from 0. The index lives in a List Index property (ViewModelPropertySymbolListIndex) that the view model must declare; without one every instance returns -1. It is written as the list changes, so it is already right in the callback that pushed or moved the view model.

getImage

Looks up an image by name. Returns a Property<Image>.

getFont

Looks up a font by name. Returns a Property<Font>.

getBlob

Looks up a blob by name. Returns a Property<Blob>.

getArtboard

Looks up an artboard property by name. Returns a Property<BindableArtboard?>: assign one of this file’s artboards from context:bindableArtboard, one of another file’s from context:decodeFile and RiveFile:bindableArtboard, or nil to clear it. An artboard chosen in the editor reads back as nil.