Subscribe on changes!

Computed properties referencing class instance properties are not updated

avatar
Sep 19th 2020

Version

3.0.0

Reproduction link

https://vue3-computed-property-reactivity-v3.itsgoingd.vercel.app

Steps to reproduce

Source - https://vue3-computed-property-reactivity-v3.itsgoingd.vercel.app/_src

What is expected?

The computedInstanceProperty value should be updated when this.classInstance.message changes.

Vue 2 demo - https://vue3-computed-property-reactivity-v2.itsgoingd.vercel.app/

What is actually happening?

The computedInstanceProperty value is not updated.


Possibly a side-effect or an intentional change in the new reactivity system in Vue 3. If this is an intentional change it should be mentioned in the upgrade guide with a migration path.

avatar
Sep 19th 2020

This has nothing to do with it being a class property.

It is a result of using proxies for the reactivity. You change the original instance directly with that timer in screen.js, you don't do it through the proxy (this.classInstance).

Consequently, the change is not detected.

This is a general restriction wit the new reactivity system: Any change to the raw source object is not observable.

Considering a migration path: That would depend a bit on the actual usecase. Either way it would be more suitable to bring up in the docs-next repo

avatar
Sep 19th 2020

Makes a lot of sense, thanks for the fast response!