Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
Is there a method to update a data object from vue when the database updates?

I'm making a web app that allows users to create an account and then join a room. Inside the room they can click a button and essentially allows them to pick who they are gonna give a gift to randomly. The problem I'm having is how do I update a data object from vue if the database updates for all users. What I mean is if a another user joined a room, the new user has the updated data object but all the other users who came before him will have the outdated data object. So what I'm essentially asking is how would vue update a data object if the database updates.

And by data object I mean something like this

data() {
 return {
  room: { name: "room", users: [] }
 }
}

Does the update() lifecycle hook do that? or computed()? And before anyone answers, remember I need it to update to ALL the users that joined the room.

I'm using vue2 since I'm using vuetify

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As Fatur said above, typically with an open-game style like this where you join a room and new users can join and leave, you would want to setup a web connection (web socket) to be constantly aware of who's in the room.

Since you're using the Vuetify framework already, you could probably add Vue Native Websocket to your project pretty easily. I've never used it, but it looks like it's a solid project that's updated on a pretty consistent basis.

The only alternative to this that I can think of immediately would be: every time the user clicks the button to gift a random user, hit the database or API for all of the current users in the room. But again, users could enter the room while you're making this request, and I don't really recommend this. Additionally, this would hammer your database or API pretty hard if you have multiple rooms, which is another reason I don't recommend this.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda