Why do we need a global state store?

As a developer, you are already familiar with global and local concepts. There are global variables that are accessible by each section of the application, but methods also have their own (local) scope and their scope is not accessible by other methods.

A component-based system also has its local and global states. Each component has its local data, but the application has a global application state that can be accessed by any component of the application. The challenge that we have met in the previous paragraph would be easily solved if we had some kind of a global variables store containing the titles of the shopping lists and each component could access and modify them. Fortunately for us, Vue's creator thought ...

Get Learning Vue.js 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.