2 way binding for nth level objects using reactive and proxies #790
jaypeerj
started this conversation in
RFC Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Start Date: (2025-08-06)
Target Major Version: (3.x)
Reference Issues: (fill in existing related issues, if any)
Implementation: stackBlitz
Summary
following on from #751 (reply in thread)
I re-emphasise the intention of @michal
put another way, true 2-way binding has been limited to primitives only.
Motivation
Composables, Pinia and/or vuex are all helpful for resolving complex state management. However, there are times where allowing the client developer to interface with a component that takes a complex object is useful (particularly for modular components that may be plug-and-play for a number of different projects/private module repos with agnostic components/etc.)
Proposal
The following uses native Proxies and vueJS'
reactive
method. It works with nth level objects and maintains 2 way binding.The method
computeDeepModel
is passed the caller SFC's props, a key and the emit object. It carries the caveat of any tool that performs recursive operations on Nth dimension object; overhead. The proposal is that a modified version of the below (likely, without the alternative)it could be added as a helper composable in the VueJS library
Example
Here is how the above could be used (i'm using unplugin hence no imports)
and its parent
see the stackBlitz for a working example
Beta Was this translation helpful? Give feedback.
All reactions