Vue.observable on an array does not really work
See original GitHub issueVersion
2.6.6
Reproduction link
https://jsfiddle.net/9L5ymbv7/
Steps to reproduce
If I do const todos = Vue.observable([]);
and try to use it inside reactive context, it does not really work. For example, observing the length of the todos
does not trigger re-run if I push to todos
.
What is expected?
That observed array would be fully reactive.
What is actually happening?
There is no reactivity.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Vue JS returns [__ob__: Observer] data instead of my array of ...
You're trying to log the data in created() before the asynchronous fetch completes, so it's still empty (except for the Observable that Vue...
Read more >Home Rolled Store with Vue.observable (Vue 2) - Vue School
Vue.observable() makes it possible to create reactive data outside of a Vue component, thus making it a viable and flexible store solution ...
Read more >On-demand Reactivity in Vue 3 - Toptal
This article will introduce you to new features and paradigms introduced in Vue 3 and demonstrate how you can leverage the new Composition...
Read more >Where to Learn about observable Arrays and Objects : r/vuejs
Hi I just started learning Vue today, and am trying to make an app. I am probably borderline intermediate at JS.
Read more >API - Vue.js
Please note that Vue does not come with a Promise polyfill, ... we recommend always working with the object returned by Vue.observable ,...
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
Ehm, arrays are objects, no?
Should I make a feature request then for arrays to be supported as well?
@Justineo just do like this:
window.state = Vue.observable({ arr: [] });
orconst state = Vue.observable({ arr: [] });
state.arr.push(‘test’);
Works like a charm for me 😃