I have a VueJS component like this
const MyComponent = Vue.extend({
props: ["myHandle"],
computed: {
name: {
get: function() { return myHandle.getName() },
set: function(newName) { myHandle.setName(newName) },
}
}
})
The problem is that setting the computed property name does not trigger VueJs to update the property. Meaning the old name is what gets displayed on re-render.
Now, I'm fairly new to VueJS and i can see how this might be code smell, but the thing is that the myHandle property is actually a handle to access data in a WebAssembly module written in rust. The rust code is where most of my state/model/source of truth lives.
The two unsatisfactory solutions i have found thus far are:
Use a method to retrieve the name instead of a computed property. Basically add a
getNamemethod to my component and change my template code from<p> Your name is {{ name }}</p>to<p> Your name is {{ getName() }}</p>. Which will cause VueJs to not cache. In the future I'm planing to do expensive computations meaning unnecessary performance costCopy state from the rust side to my component. This I do not want to do since I would get multiple source of truth.
So is there some way to:
A: Get VueJS to understand that myHandle.setName is a mutating method that should cause name computed property to be updated.
B: Manually trigger an update.
C Solve it in some other manner?