DEV Community

loading...

Discussion on: Watch for Vuex State changes!

Collapse
yassineche profile image
Yassine Cheddadi

Hello,

I'm really grateful for this article
But using "computed: mapState(['status'])", denied you to put another computed func,

How did you solve this problem ?

Collapse
viniciuskneves profile image
Vinicius Kiatkoski Neves Author

Hey Cheddadi,

If I understood you correctly you want to have this mapState + another computed property, right?

If so, you can do it like that:

computed: {
  ...mapState(['status']),
  myComputedProperty() {}
}

You can read more about it here: vuex.vuejs.org/guide/state.html#ob...

Hope it helps! Have a nice day!

Collapse
yassineche profile image
Yassine Cheddadi

Hey Neves,

Yes, its work fine now.

I'm just wondering about these three dot (...) !! What they do?

Thread Thread
viniciuskneves profile image
Vinicius Kiatkoski Neves Author

Nice to hear that!

It is called Destructuring assignment. You can read more about it here: developer.mozilla.org/en-US/docs/W...
In short (from MDN)

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.