signalr icon indicating copy to clipboard operation
signalr copied to clipboard

Client without Receiver, Server without Hub: Set specific handler funcs instead

Open philippseith opened this issue 4 years ago • 0 comments

Callback handlers in the client should not only be possible with public methods in a class given by the Receiver option, but also by passing single handler functions

action := func(param …interface{}) { ... }

NewClient(..., ReceiveFunc(„ProductUpdate“, action), ...)

Originally posted by @philippseith in https://github.com/philippseith/signalr/issues/65#issuecomment-922462238

The server interface could be extended using the same pattern:

method := func(param ...interface{}) []interface{} { ... }

NewServer(..., Method("AddProduct", method) ...)

ReceiveFunc can be used also with the server.

philippseith avatar Sep 19 '21 19:09 philippseith