C
C#2mo ago
Adi

How do you loosely couple SignalR service to the rest of application?

Lookin for some advice on how to loosely couple SignalR hub with rest of my application, maybe some sanity check? Right now 2 things come to my mind: 1. Make a service encapsulating SignalR stuff and use its interface to expose in the rest of my application. This solves issue of bi-directional coupling since i can expose methods that talk to connections by connection Id and events that fire when connection sends something. 2. Use MediatR to facilitate bi-directional communication. This has the added benefit of tidying things up but has some drawbacks: 1. I can't find neat way to use Rx stuff to do things such as throttling 2. I now have bi-directional dependency on mediator and request handlers 3. Still didn't figure out a way to package IHub somewhere Is there a third way? What do you guys think/do?
1 Reply
Adi
Adi2mo ago
Okay I've tried writing out both and figured that Mediator will not work for my applciation. I don't want to write any request handles in my hubs and maybe this would work for application where hub is a bit more central But I'm building with redundancy in mind and I want to have several hubs with backplane later so Rx & Aggregator it is