Link to Codepen: https://codepen.io/codingkiwi_/pen/XWMBRpW
Let's consider a scenario where you have a class:
class MyClass {
constructor(){
this.entries = ["a"];
//=== example change triggered from INSIDE the class ===
setTimeout(() => {
this.entries.push("c");
}, 1000);
}
}
Now, in a component, you instantiate and get an instance of that class:
const { reactive } = Vue;
const App = {
setup() {
const myobject = reactive(new MyClass());
//=== example change triggered from OUTSIDE the class ===
setTimeout(() => {
myobject.entries.push("b");
}, 500);
return {
myobject
};
}
}
The displayed entries in the DOM for the myobject.entries array will be "a"
and "b"
, but not including "c"