Tips for updating the state in a Vuex store across all users

Hey there, I'm currently using Nuxt for a CRM tool but encountering an issue with Vuex. When I update the store, it doesn't reflect the changes for all users. My setup involves static deployment on a VPS and communication with a MySQL database via REST API. Additionally, I am utilizing the module mode for Vuex.

For instance, here's how my store is structured:

role/actions.js

export default {
  updateProsit: (context, value) => {
    context.commit('updateProsit', value)
    const equipe = (value % 11) + 1
    context.commit('updateEquipe', equipe)
  }
}

role/getters.js

export default {
  // getters code here...
}

role/mutations.js

export default {
  // mutations code here...
}

role/state.js

export default () => ({
  // state data here...
})

When updating NumProsit, it should also update equipe and subsequently populate currentEquipe based on the role. This mechanism is working as intended for me but not for other users. I'm unsure whether storing this data in the database or finding a Vuex-specific solution would help resolve this discrepancy.

I may have misunderstood some aspects of Vuex. Appreciate any insights!

Thank you.

Answer №1

When it comes to handling app state within the browser for a single user, Vuex is the way to go. However, if you need to modify the state across multiple users, you'll need to utilize a websocket implementation. By implementing websockets, your backend can efficiently broadcast any changes to all clients connected to your application.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there any method to transfer the value from form1 to form2 prior to submitting form2?

I am facing a challenge with two forms on a single page. Is there a way to retrieve the selected value from form1 before submitting form2? This will allow me to insert both values (selected value from form1 and input box value from form2) into a table as a ...

Searching by object id from the front-end: A step-by-step guide

Within my collection of meals, there is a specific document I am working with: # Meals collection { name: "burger", tag: ObjectId(63d6bb22972f5f2fa97f1506), } Now, as I navigate through my React application, I find myself needing to send a ...

Tips for manipulating elements in arrays using JavaScript and ReactJS: Adding, editing, updating, and deleting items

I currently have a form that looks like this: https://i.sstatic.net/nuaiM.png Below is the table where I am adding elements to an array: https://i.sstatic.net/EvDpX.png Using the code excerpt below, I am adding values from the form into an array: cons ...

Tips on improving a function that verifies the existence of an image used as a CSS background to output a boolean value

I have encountered a challenge while working on a react file-upload component. The issue at hand is relatively simple - I aim to display an icon corresponding to the file extension for each uploaded file. These icons are loaded through css as background im ...

Passing the value of the src attribute from the img tag to the child component via the parent component in Vue: A step-by-step

I have a situation where I need to pass the src attribute from a parent component to a child component using defineProps in order to display an image. Here is the code for my parent component: <script setup> import item from "./item.vue" ...

What is the best approach for connecting Advanced Custom Fields in WordPress to components in my Next.js frontend using GraphQL?

Currently, I am in the process of constructing a website by utilizing WordPress as the headless CMS and NextJs for my frontend. My dilemma lies in using the free version of ACF and wanting to dynamically query and map ACF to components in Next when generat ...

Encountering a FeathersJS Twitch OAuth 401 Unauthorized error

I'm a newcomer to FeathersJS and I've been trying to set up OAuth login with Twitch. Following the steps outlined in the Feathers documentation for setting up GitHub login OAuth, I created a Twitch OAuth application. However, when attempting to s ...

Encountering Syntax Error while running `ionic serve` in IONIC2

I'm stuck on this Syntax error and I can't figure out what went wrong. It keeps showing up even though I copied the code directly from the official ionic2 docs. SyntaxError: D:/Manson/Arts/Ionic/IonicTodo2/app/pages/list/list.js: Unexpected toke ...

Obtaining data from one form to validate on the web in Lotus Notes

I have a radio button field on my custom form in Lotus Notes. When the radio button is selected as "Yes", it reveals a hidden link. Clicking on this link opens another form. If "Yes" is still selected in the main form, specific fields on the second form ...

What steps are needed to successfully integrate bootstrap.js, jquery, and popper.js into a project by using NPM to add Bootstrap?

I've successfully set up a project and incorporated Bootstrap via npm. However, I'm facing challenges in loading the necessary javascript files for Bootstrap components. It's important to note that I am utilizing a Vagrant Box (virtual machi ...

Choose the OK button on the modal during the testing phase

I am having difficulty selecting an element on my webpage using testcafe because I am not very familiar with selectors. I am open to choosing it in the JSX or HTML, but I am struggling with both methods. Once I click the "LayerAddingPopUpButton", a modal a ...

Ways to conceal a message button on a website when a user logs out

I am looking for assistance with hiding the message button on my website after a user logs out. The message option should be disabled upon logout using a combination of Javascript and PHP. Can anyone help me with this issue? Below is the code for the butt ...

Display a sneak peek on a separate tab

I have an editor on my website where users can input and edit their own HTML code. Instead of saving this to a database, I want to display the current user's HTML code in a new window using JavaScript. How can I achieve this without storing the code p ...

Controlling a table using JavaScript and jQuery

Implementing this particular functionality in JavaScript/jQuery has been quite challenging. My initial idea involved using numerous ids, but as the content will be dynamic, it makes more sense to utilize classes instead. Consider the table below: <tab ...

performing a request to Axios API with the inclusion of ${item} within the URL

I am having trouble with calling axios in Vuetify due to backticks and ${} within the URL. I believe I need to convert it into JSON format, but my attempts have been unsuccessful. Could you please provide an explanation? Here is the code snippet. Whenever ...

What is the best way to retrieve the post JSON data in the event of a 404 error?

When my service call returns a 404 error, I want to display the server's message indicating the status. The response includes a status code and message in JSON format for success or failure. This is an example of my current service call: this._trans ...

javascript / php - modify input fields according to selection change

Can anyone help me with an issue I'm facing? I want to update multiple textfields whenever a new option is selected from my dropdown menu. I've written the following code, but it's not working as expected. Can someone figure out what's ...

Is using JQuery recommended for implementing onclick and onchange events?

Hello there, I'm completely new to the world of jQuery and currently facing a bit of confusion. Here's my dilemma: should I be utilizing jQuery with the onclick event or the onchange event for an element using something like this: $(selector).som ...

Is there a way for me to receive the response from the this.$store.dispatch method in vue.js 2?

Here is the structure of my component : <script> export default{ props:['search','category','shop'], ... methods: { getVueItems: function(page) { this.$store.disp ...

Transmit an array to a PHP script in WordPress using Ajax

I am attempting to pass an array from a JavaScript file to a PHP file on the server, but I am encountering difficulties when trying to access the array in PHP. Below is the function in my JS file: var sortOrder = []; var request = function() { var js ...