Closed brunobraun closed 7 years ago
Hello,
is it possible to set a HubProxy to a variable and access its methods? For example:
conectarChat() { const connection = signalr.hubConnection(url); connection.logging = true; const proxy = connection.createHubProxy('chatHub'); this.proxy_signalr = proxy; // ... connection start and other stuff }
componentDidMount() { this.conectarChat(); this.proxy_signalr.on('msgRecebida', (id_enviou, id_recebeu, mensagem) => { //some function }); }
If the .on method is within conectarChat() function it works perfectly.
Thanks, Bruno
This works for the .invoke method: this.proxy_signalr = connection.createHubProxy('chatHub');
I changed my logic to let the .on methods access signalr proxy inside the main method and solved my problem.
Hello,
is it possible to set a HubProxy to a variable and access its methods? For example:
If the .on method is within conectarChat() function it works perfectly.
Thanks, Bruno