Documentation Index
Fetch the complete documentation index at: https://uat.rive.app/docs/llms.txt
Use this file to discover all available pages before exploring further.
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
getNumber(name: string) -> Property<number>?
Returns the numeric property with the given name, or nil if not found.
local vmi = context:viewModel()
if vmi then
local score = vmi:getNumber('score')
if score then
print(score.value)
end
end
getTrigger
getTrigger(name: string) -> PropertyTrigger?
Looks up a trigger property by name.
Returns a PropertyTrigger.
local vmi = context:viewModel()
if vmi then
local myTrigger = vmi:getTrigger('myTrigger')
if myTrigger then
myTrigger:fire()
end
end
getString
getString(name: string) -> Property<string>?
Looks up a string property by name.
Returns a DataValueString.
local vmi = context:viewModel()
if vmi then
local heading = vmi:getString('heading')
if heading then
print(heading.value)
end
end
getBoolean
getBoolean(name: string) -> Property<boolean>?
Looks up a boolean property by name.
Returns a DataValueBoolean.
local vmi = context:viewModel()
if vmi then
local darkMode = vmi:getBoolean('darkMode')
if darkMode then
print(darkMode.value)
end
end
getColor
getColor(name: string) -> Property<Color>?
Looks up a color property by name.
Returns a DataValueColor.
local vmi = context:viewModel()
if vmi then
local primaryColor = vmi:getColor('primaryColor')
if primaryColor then
primaryColor.value = Color.rgba(255, 0, 0, 155)
end
end
getList
getList(name: string) -> PropertyList?
Looks up a List property by name.
Returns a PropertyList.
local vmi = context:viewModel()
if vmi then
local enemies = vmi:getList('enemies')
if enemies then
enemies:pop()
end
end
getViewModel
getViewModel(name: string) -> PropertyViewModel?
Looks up a view model property by name. Returns a PropertyViewModel.
local vmi = context:viewModel()
if vmi then
local nestedVM = vmi:getViewModel('MyVM')
end
getEnum
getEnum(name: string) -> PropertyEnum?
Looks up an enum by name.
Returns a PropertyEnum.
local vmi = context:viewModel()
if vmi then
local textAlignment = vmi:getEnum('textAlignment')
end
instance
instance(instanceName: string?) -> ViewModel
Creates a new instance of the ViewModel.
Pass instanceName to specify an existing instance from the file to use as template
function init(self: VMNameNode, context: Context): boolean
local vm = context:viewModel()
if vm then
local newInstance = vm:instance()
local age = newInstance:getNumber('age')
if age then
age.value = 99
end
end
return true
end
getIndex
Returns the index.
Returns -1 if view model does not have an index available.