Extend the binding API to support structured persistent storage #2978
Aues6uen11Z
started this conversation in
Ideas / Feature Requests
Replies: 2 comments 3 replies
-
Thanks, @Aues6uen11Z! Creating nested structures like ui.number().bind_value(robot, ('motors', 'left_axis', 'max_speed')) sounds very convenient. I wonder if an API like this would be even more handy: ui.number().bind_value(robot, 'motors.left_axis.max_speed') But this would cause conflicts with dictionary keys containing dots... Or could we use ui.number().bind_value(robot, 'motors', 'left_axis', 'max_speed') |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hey BR |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As discussed in #2923, the existing methods find it difficult to create a multi-layered JSON structure in persistent storage (such as app.storage.general), which makes subsequent retrieval and access challenging. Directly using libraries like addict to improve
PersistDict
might bring some potential problems.Therefore, my idea is to improve the binding API by automatically creating non-existent keys when binding dictionary data. This way, we can achieve the goal without affecting the existing binding usage. Specifically, I added the
_convert_target
method as shown below.Then we can use it like this:
This method is indeed a bit quirky because the original
target_name
ofbind_value
was all of typestr
, and nowtuple
type has been specially added for dict, which seems inconsistent. I wonder if there is a better implementation method?Beta Was this translation helpful? Give feedback.
All reactions