Odonno / ngrx-signalr-core

A library to handle realtime SignalR (.NET Core) events using @angular, rxjs and the @ngrx library
https://www.npmjs.com/package/ngrx-signalr-core
MIT License
28 stars 13 forks source link

[Help][Best practise] When/Where is the best location to dispatch createSignalRHub(hub) ? #104

Open hocino opened 1 year ago

hocino commented 1 year ago

Hello,

I use Odonno on one project. I have one problem with the action createSignalRHub(hub).

I put this.store.dispatch(createSignalRHub(hub)); in the container of one component which needs signalr. The first time when I display the component everything is good but when I come back a second time on this component, I dispatch a second time createSignalRHub(hub) and the effect link to signalrHubUnstarted an error is thrown because is enabled to add existing method.

I tried to dispatch createSignalRHub(hub) in a guard only when the hub doesn't exist, problem the selector selectHubStatuses doesn't work when *createSignalRHub(hub) is not yet dispatched.

So I think I misunderstood something... May you help me to know when or where dispatch createSignalRHub(hub) ? What is the good practise ?

Thanks a lot for your help