Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set hubProxy to variable #27

Closed
brunobraun opened this issue May 29, 2017 · 1 comment
Closed

Set hubProxy to variable #27

brunobraun opened this issue May 29, 2017 · 1 comment

Comments

@brunobraun
Copy link

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

@brunobraun
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant