stomp-js / rx-stomp

STOMP adaptor for RxJS
Apache License 2.0
113 stars 21 forks source link

afterConnect in RxStompConfig #442

Closed krij03 closed 2 years ago

krij03 commented 2 years ago

Hello, im trying to use beforeConnect to increase reconnectDelay every time its called. I managed to make that work like this this.beforeConnect = (stompClient => { stompClient.stompClient.reconnectDelay += X; }); Now i need to reset the reconnectDelay after successful connection. The only way was to subscribe to connectionState$ inside the component and reset it there. I dont think thats ideal, is there a better way?

I think the best way would be if RxStompConfig had something like afterConnect but unfortunately it doesnt.

kum-deepak commented 2 years ago

The underlying @stomp/stompjs has onConnect property.

One of the limitations of that design is that it allows only one callback. The RxStomp targetted to allow multiple handlers for (the equivalent of) onConnect and similar concepts. One option was to keep an array of handlers with the ability to register/deregister handlers. It was becoming too similar to an RxJS Subject. So, connected$ was kept as an RxJS Behaviour Subject.