Vuex/Vue: how to deep watch a mapped state?

Viewed 220

I am importing a mapped state into a component:

...mapState('data/story', {
  fullStories: 'stories',
}),

this will give fullStories the value of the state stories, which is an object.

An example would be :

this.fullStories = { storyName: "Blah Blah", isActive: false };

I am trying to use a watch on isActive, a property of fullStories. How exactly would I do that?

1 Answers

You can try with :

...mapState('data/story', {
  isActive: (state) => state.fullStories.isActive
})

or you can create vuex getter to get a isActive from store object

Related