Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
How to listen to custom event dispatched by third party library in VUE JS

I am implementing agora chat in vue js where there is object which emits 6 events. How can I listen to those in VUE JS. Here is its code in core javascript:

       this.agora.conn = new AC.connection({
            appKey: this.agora.appKey,
        });


       this.agora.conn.addEventHandler("connection&message", {
            // Occurs when the app is connected to Agora Chat.
            onConnected: () => {
                console.log("App connected.");
            },
            // Occurs when the app is disconnected from Agora Chat.
            onDisconnected: () => {
                console.log("App disconnected.")
            },
            // Occurs when a text message is received.
            onTextMessage: (message) => {
                console.log("Message Recieved: ",message);
            },
            // Occurs when the token is about to expire.
            onTokenWillExpire: (params) => {
                console.log("Token is about to expire. ",params)
                this.refreshToken(this.agora.username, this.agora.password);
            },
            // Occurs when the token has expired. You need to get a token from your app server to log in to Agora Chat.
            onTokenExpired: (params) => {
                console.log("Token is expired. ",params)
                this.refreshToken(this.agora.username, this.agora.password);
            },
            onError: (error) => {
                console.log("on error: ", error);
            },
        });

Here agora is the data member in the component and this above code is in mounted hook. I have noticed console the SDK is dispatching the events but this listener is not catching any. Here is agora data member:

agora : {
         baseUrl : "https://a41.chat.agora.io",
         appKey : "******",
         username : "fana",
         password: "123",
         conn : null
         }
almost 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda