DEV Community

Discussion on: Watch for Vuex State changes!

Collapse
 
opolancoh profile image
Oscar Polanco • Edited

Hi Vinicius,

It's just to try to undesrstand the Observable pattern. When you unsubscribe, you cancel Observable executions and release resources. If you don't do it, you'll probably avoid memory leaks. I don't know if Vuex does that for you.

Thread Thread
 
viniciuskneves profile image
Vinicius Kiatkoski Neves

Hey Oscar,

Exactly. Once you subscribe you have to unsubscribe unless your Subject has some kind of check to remove the Observer in case it doesn't exist anymore.
For Vuex you've to do it manually, which means you've to unsubscribe once your component is destroyed.
If you don't do it you might end up in trouble as you mentioned =]

I didn't get if you were asking or not but I'm just confirming hehehe

In case you've any other question, let me know =]

Thread Thread
 
opolancoh profile image
Oscar Polanco

Thanks!!