Skip to content

Add getName to experimental ViewModelInstance API#463

Open
mfazekas wants to merge 1 commit into
rive-app:masterfrom
mfazekas:feat/view-model-instance-get-name
Open

Add getName to experimental ViewModelInstance API#463
mfazekas wants to merge 1 commit into
rive-app:masterfrom
mfazekas:feat/view-model-instance-get-name

Conversation

@mfazekas

@mfazekas mfazekas commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds suspend fun ViewModelInstance.getName() to the experimental API, returning the editor-assigned instance name resolved by the command server.

Consumers migrating from the classic API currently lose the instance name: CommandQueue only exposes getViewModelInstanceNames(file, viewModelName) (the per-view-model name list), which cannot tell an existing instance which one it is. Instances created by name echo back what the caller already knew, while default, blank, nested (reference-path) and list-item instances have no way to learn their name at all.

The command queue protocol has no message carrying an instance's own name (getViewModelInstanceViewModelName returns the view model's name), so the binding resolves it with runOnce on the command server thread via CommandServer::getViewModelInstance()->name() and calls back into Kotlin from there — no runtime protocol change needed.

Covered by unit tests and an instrumented test asserting parity with the classic API's ViewModelInstance.name for named, default, blank, nested and list-item instances against data_bind_test_impl.riv.

The same gap exists in the rive-ios experimental API (RiveRuntime 6.20.4 ViewModelInstance has no name member); the same design would apply there for parity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant