Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49308

Stop the execution of the application when I make a query to firebase?

$
0
0

@Alejandro2396 wrote:

What can I do so that the code of the application does not continue executing while doing the query to firebase, since it returns an empty value or creates a new id even if it exists. Thank you

iniciar_chat(idUsu1: string, idUsu2: string): string {
    let existeConversacion: boolean = false;
    let idChat: string = "";
    this.afDB.database.ref().child('/chats-info')
      .orderByChild("idUsuers")
      .equalTo(idUsu1 + "_" + idUsu2)
      .on('child_added', (snapshot) => {
        existeConversation = true;
        idChat = snapshot.key;
      });
      let datos_chat = {
        idUser1: idUsu1,
        idUser2: idUsu2,
      };

      idChat = this.afDB.createPushId();
      this.afDB.database.ref().child(`/chats-info/${ idChat }`).update(datos_chat);

    return idChat;
  }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49308

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>