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

263
Visualizações
update UI with signalR callback

I’m trying to update my UI based off a signalR callback in angluarJs with typescript. I get the callback every time, but I’m getting random results to update the UI. Sometime it works and sometimes it doesn’t without changing code.

Here is my controller constructor that listens to the signalR events:

    var chat = this.$.connection.chatHub;

    chat.client.userListUpdated = (name: any, message: any): void => {

        this.$scope.$apply(() => {
            this.UserList = message; 
        });

    };

    this.$.connection.hub.start().done(() => {        
    });

Like I said I get the callback every time I expect to. It's just this.UserList is bound to the UI and doesn't work every time. It’s inconsistent, it works sometimes and doesn’t other times.

When it works the scope looks like this:

enter image description here

And when it doesn't update scope looks like this:

enter image description here

I noticed when it doesn’t work I get allot more properties in the scope, and the parent is null, watchers is null. But the vm ClassRoomRaciliatorHomeController is the same.

This is hard to figure out cause it happens inconsistency, it works, works, then doesn’t work, then works… ect…

Any insight would be helpful.

I tried doing rootscope.apply() see the same thing. Tried replacing function with () =>() syntax with typescript and see the same thing…

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think I was able to get around this by using a broadcast service to publish out the message once it gets received by the signalr handler. Then the broadcast event listener does the this.UserList = … I think this lets the scope use the controller scope instead of dealing with the scope in the signalr event handler.

over 4 years ago · Santiago Trujillo Relatório
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