D
D
Dima2021-06-30 17:40:01
Vue.js
Dima, 2021-06-30 17:40:01

How can I make a type of chat but without a backend?

To save information, I use firebase realtime database
The idea is simple.
there is a text field and a button to add text to the object

<textarea   v-model="textarea"></textarea>
    <button @click="addText"> add</button>


  data(){
    return{
      textarea:null,
      texts:[ ]
    }
  },
methods:{
    addText(){
      this.texts.push({user:"admin", message:this.textarea})
    }
  }


then just display the list
<ul v-for="message in texts" :key="message">
  <li><b>{{message.user}}</b> {{message.message}}</li>  
</ul>


And everything is OK, within one tab. but if you open it in two tabs, it is not added to one array, but to different . It is logical.
But how do you trigger a component re-render if there is a change in two different browsers?

Can it be done without backing? otherwise Google gave out that it’s possible with a node and sockets,

it’s clear that you can throw a request every minute and check if anything has changed, but this is a crutch after all)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alice, 2021-06-30
@w3bsmes

Google already answered your question

A
Aetae, 2021-06-30
@Aetae

You can't do without backing. Node and sockets - back. You already have firebase. Here, use it .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question