Skip to content

feat: db list and image support#371

Merged
damzobridge merged 4 commits into
mainfrom
feature/db-lists-and-images
Jul 7, 2025
Merged

feat: db list and image support#371
damzobridge merged 4 commits into
mainfrom
feature/db-lists-and-images

Conversation

@damzobridge

Copy link
Copy Markdown
Contributor

This PR adds reactive hooks for fetching List and Image property types.

New Hooks

useViewModelInstanceImage

  • Returns: { setValue } - setter function to update images

useViewModelInstanceList

  • Returns: Object with list manipulation functions:
    • length - Current list length
    • addInstance(instance) - Add item to end
    • addInstanceAt(instance, index) - Insert item at specific index
    • removeInstance(instance) - Remove by instance reference
    • removeInstanceAt(index) - Remove by index
    • getInstanceAt(index) - Get item at index
    • swap(indexA, indexB) - Swap two items

Usage Examples

Image Property:

const { setValue: setImage } = useViewModelInstanceImage('profileImage', viewModelInstance);

// Load and set image
const imageBuffer = await fetch(imageUrl).then(r => r.arrayBuffer());
const decodedImage = await decodeImage(new Uint8Array(imageBuffer));
setImage(decodedImage);
decodedImage.unref(); // Clean up

List Property:

const { length, addInstance, getInstanceAt, removeInstanceAt } = 
  useViewModelInstanceList('todoItems', viewModelInstance);

// Add new todo item
const todoViewModel = rive?.viewModelByName?.('TodoItem');
const newItem = todoViewModel.instance();
addInstance(newItem);

// Remove first item
removeInstanceAt(0);

@bodymovin bodymovin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@damzobridge
damzobridge merged commit c4239ab into main Jul 7, 2025
1 check passed
@damzobridge
damzobridge deleted the feature/db-lists-and-images branch July 7, 2025 21:23
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.

2 participants