Accessing embedded VM instance properties on Web
I’m using @rive-app/webgl2-advanced (Web low-level API) and trying to work with nested ViewModels but not being able to access the elements means I cant have re-used base components to standardise my elements 😥.
I created embed_vm_test.riv with this setup:
Artboard “Artboard Sub” uses ViewModel ArtboardSubVM with property subNum.
Default artboard “Artboard Main” uses ViewModel ArtboardMainVM with a nested viewModel property propertyOfArtboardSubVM (type ArtboardSubVM).
One instance of ArtboardSubVM is named ArtboardSubInstance1 with subNum = 1.
From Artboard Main in Web runtime, I want to get:
The VM definition name of propertyOfArtboardSubVM (expected: ArtboardSubVM)
All instance names of that VM (expected: ["ArtboardSubInstance1", "ArtboardSubInstance2"])
The currently bound instance name for that nested property (expected: ArtboardSubInstance1)
The value of ArtboardSubInstance1.subNum (expected: 1)
Is there an official/direct API for this from ViewModelInstance?
I expected something conceptually like:
mainInst.viewModel("propertyOfArtboardSubVM").viewModel.name
mainInst.viewModel("propertyOfArtboardSubVM").viewModel.getInstanceNames()
mainInst.viewModel("propertyOfArtboardSubVM").instanceName
mainInst.viewModel("propertyOfArtboardSubVM").number("subNum").value
Right now I have to do fallback matching by property signature, which is fragile and not really working well at runtime for embedded property instance variables.
Could you confirm the intended runtime API for nested VM definition + bound instance identity?