Yes, you're correct. user is in the store and I'm trying to get data from Firestore when user changes. But this.$store.watch never gets invoked. If I console.log it in mounted it's null. But when I console.log it in beforeUpdate it's set. Yet, this.$store.watch is never called.
If I use the normal watcher on user it gets invoked, but the values don't seem to be there. I can log them and they are undefined. Perhaps this is because user is a Vuex computed property. I tried deep: true but then the (non-store) watcher is invoked twice, neither time with the data I need.
Any idea why the watcher isn't being called even through user is obviously changing?
Please check store.js and App.vue. I've tried to create a fetch logic (full user and just username). Please mind the comments and play with comment/uncomment the deep and immediate options.
Also mind the first warning here vuejs.org/v2/api/#vm-watch once you hit the Fetch new username button.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes, you're correct.
useris in the store and I'm trying to get data from Firestore whenuserchanges. Butthis.$store.watchnever gets invoked. If Iconsole.logit inmountedit's null. But when Iconsole.logit inbeforeUpdateit's set. Yet,this.$store.watchis never called.If I use the normal watcher on
userit gets invoked, but the values don't seem to be there. I can log them and they are undefined. Perhaps this is becauseuseris a Vuex computed property. I trieddeep: truebut then the (non-store) watcher is invoked twice, neither time with the data I need.Any idea why the watcher isn't being called even through
useris obviously changing?Thanks for your help!
Hey Adam, to help our discussion I've created this Codesandbox: codesandbox.io/s/agitated-haze-ojdun
Please check
store.jsandApp.vue. I've tried to create a fetch logic (full user and just username). Please mind the comments and play with comment/uncomment thedeepandimmediateoptions.Also mind the first warning here vuejs.org/v2/api/#vm-watch once you hit the
Fetch new usernamebutton.