[Vuejs]-Do I need to use a vuex for recording markup data?

0đź‘Ť

Whilst @ceejayoz has a valid point in the comments, I’d like to offer one other angle as to how we could view (pun intended) this.

I don’t know the scale of your application, but as “opened/closed” is a flag (a state), then Vuex seems a fine place for it. Maybe one day you’d like to start tracking some (any) interactions or other components would become dependent on a panel’s closed/open state. Then instead of having the panel component emit events, other components or trackers could simply keep an eye on the state (Vuex).

Now, there’s always the YAGNI principle and that’s why I brought up the application scale. But I’ve set up all my Vue apps with a sort of state manager, since it makes component-to-component communication later down the road a breeze. Another point in the favour of Vuex is that it’s already part of your project, so it’s not even a question of integrating it, just extending it for your app’s internal state as well.

Leave a comment