[Feature] useReactives
See original GitHub issueI have an idea to make a helper function similiar to toRefs
named toReactives
which gets a ref object and decomposes it into a normal object which every key is a reactive
instead of a ref
.
I wanted to make this mainly for decomposing props
because right now we only have toRefs
to do this and this forces us to have a .value
every time we want to reference props in code.
My idea was that since reactive()
deeply unwraps refs
, such implementations would work.
function toReactives(refObject) {
const result = {};
for (const key of Object.keys(refObject)) {
result[key] = reactive(toRef(refObject, key));
}
return result;
};
function toReactives(refObject) {
const result = {};
for (const key of Object.keys(refObject)) {
result[key] = reactive(computed(() => refObject[key]));
}
return result;
};
function toReactives(refObject) {
const result = {};
const refs = toRefs(refObject);
for (const key of Object.keys(refs)) {
result[key] = reactive(refs[key]);
}
return result;
};
but neither works, ref
s are not unwrapped in any of these. i am ok to submit a PR if i be able to fix this.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Reactive variables - Apollo GraphQL Docs
A query "depends on" a reactive variable if any of the query's requested fields defines a read function that reads the variable's value....
Read more >How to use reactives in loops. What works, what doesn't and ...
How to use reactives in loops. What works, what doesn't and why. ... server <- function(input, output, session) {. rv <- reactiveValues(one =...
Read more >Quick Start - ahooks 3.0
useRequest organizes code through a plug-in pattern, the core code is extremely simple, and can be easily extended for more advanced features.
Read more >Getting Started with React | Simple and Fun Reactivity
It also specifies a cleanup function that will run when the component that uses the resource is unmounted. Next, we'll use the useResource...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
reactive
/ JS itselfvue-global-api
will only include vue’s composition-api itself for nowclose by #671