Exploring Vuex

Vuex, is a state management library for Vue.js applications. In this specific script "store.js", a Vuex store is being created.

Directory

"store.js" can be found in src/components/state-storage

Explanation

// Importing the createStore function from the Vuex library
import { createStore } from 'vuex';

This line imports the createStore function from the 'vuex' library. createStore is used to create a Vuex store, which is a centralized state management store for Vue.js applications.

// Creating a Vuex store instance
const store = createStore({
  // State object contains the application's state
  state: {
    // < LOCAL
    domainBackend: "http://127.0.0.1:8000",
    domainFrontend: "http://localhost:8082",
    // > LOCAL
    // < LIVE
    // domainBackend: "https://mapmama.com",
    // domainFrontend: "https://mapmama.com",
    // > LIVE
  },
});

Here, a new Vuex store is created using the createStore function. The store is configured with an initial state object. Two properties: domainBackend and domainFrontend. These properties represent the backend and frontend domains. The comment blocks LOCAL and LIVE indicate that either the local or live development environment should be used

Finally, the configured store is exported as the default export of this module. This allows other parts of the application to import and use this store.

Last updated