Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR function return value

I created a SignalR hub which contain the following hub function:

public bool GetStatus()
{
    return true;
}

I'm want to call this function from my JS code and get the request of this call. Something like this:

var result = hub.server.getStatus();
if (result)
    alert('success');

Is this possible without returning Task of bool?

Thank you.

like image 953
No1Lives4Ever Avatar asked Oct 27 '14 18:10

No1Lives4Ever


1 Answers

No. The SignalR JavaScript client is non-blocking; you will need to follow the Promise interface, like so:

hub.server.getStatus().done(function(result) { 
    if (result) {
        alert('success'); 
    }
});
like image 97
wgraham Avatar answered Oct 19 '22 18:10

wgraham