React native 如何将hubProxy signer设置为变量react native?
是否可以将HubProxy设置为变量并访问其方法? 例如:React native 如何将hubProxy signer设置为变量react native?,react-native,signalr,React Native,Signalr,是否可以将HubProxy设置为变量并访问其方法? 例如: conectarChat() { const connection = signalr.hubConnection(url); connection.logging = true; const proxy = connection.createHubProxy('chatHub'); this.proxy_signalr = proxy; // ... connection start a
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
});
}
如果.on方法在conectarChat()函数中,则它可以正常工作
谢谢,
布鲁诺