-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add data binding lists support #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
8e5e7b2 to
6712d5b
Compare
Adds ViewModelListProperty for dynamic list management at runtime. Closes #11
6712d5b to
1eb2f26
Compare
…k-form - addInstance -> append - insertInstance -> insert - removeInstance -> remove - removeInstanceAt -> removeAt
| * A list property that contains a dynamic collection of {@link ViewModelInstance} objects. | ||
| * @see {@link https://rive.app/docs/runtimes/data-binding#lists Rive Data Binding Lists} | ||
| */ | ||
| export interface ViewModelListProperty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things to consider:
- We don't HAVE to name these similar to android/ios. We can use the naming convention that matches what is expected when working with lists in RN.
- We could add additional methods/overloads if those are commonly used in RN. For example in Dart I added
firstOrNullinstead of throwing, and overloads foroperator []andoperator[]=. Maybe something like this possible here to
@override
ViewModelInstance operator [](int index) => instanceAt(index);
@override
void operator []=(
int index,
covariant FFIRiveViewModelInstanceRuntime value,
) =>
insert(index, value);
| try { | ||
| val numberProper = viewModelInstance.getNumberProperty(path) | ||
| return HybridViewModelNumberProperty(numberProper) | ||
| // Returns null if ViewModelException is thrown for iOS parity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! This is what we did from the start. Nice abstration then!
HayesGordon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just need to decide if these methods names will be most familiar for RN
|
Oh and all of the abstraction and Nitro is really paying off here 🙌 . This is really minimal code for a large feature. |
Summary
Adds
ViewModelListPropertyfor dynamic list management at runtime, for now no hook just low level methodsAPI
length- get list sizeinstanceAt(index)- get ViewModelInstance at indexappend(instance)- add to end of listinsert(instance, index)- insert at positionremove(instance)- remove by referenceremoveAt(index)- remove at indexswap(index1, index2)- swap itemsaddListener(callback)- observe changesExample
Test plan
Closes #11