Make SignalRHub.send<T> method return a value
Closed this issue · 1 comments
Spontifixus commented
In a previous project I used the ms-signalr-client
package and wrapped the SignalR hub myself. The implementation of the send method there looked somewhat similar to this:
async invoke(hubName: string, methodName: string, ...args: any[]): Promise<any> {
try {
let result = await this.connection.proxies[hubName].invoke(methodName, ...args);
log.debug(`${hubName}.${methodName}`, result);
return result;
} catch (error) {
log.error(log.info(`Error invoking ${hubName}.${methodName}`, error));
return null;
}
}
Methods implemented on the Hub can have a return value, and this implementation (or a similar one) ensures that this value can be used by the application consuming the SignalR service.
Spontifixus commented
Maybe it would be an idea to rename the send
-method to invoke
, to reflect that it cannot only be used to send data to the server but also to receive data from it.