I need to pass some data to the function i wanna render, but i dont know the syntax to do so.
Code:
var connection = new signalR.HubConnectionBuilder().withUrl("/hubFilas").build();
connection.start().then(function () {
var time = setInterval(function () {
connection.invoke("renderComponent").then(function (o) { DisplayHub(o) }).catch(function (err) {
return console.error(err.toString());
});
}, 120000)
Any ideas?
You just pass the data as parameter to the invoke
call. As described in the docs for sample hub:
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
=> await Clients.All.SendAsync("ReceiveMessage", user, message);
}
You can invoke the method via following call:
connection.invoke("SendMessage", user, message);
Also check out: