sente
sente copied to clipboard
Allow channel setup without connecting
Hi,
Thank you very much for sente, it really does save a lot of work!
I have two somewhat related issues:
- It would be useful if I could set up the channel without connecting immediately.
- When reconnecting, it would be useful to be able to pass new params.
The usecase for 1) would be to set up the channel as part of the system (and get hold of :ch-recv
and :send-fn
) but not connect just yet if the user needs to authenticate first (e.g., fetch an authentication token through ajax). This would avoid errors being logged while authentication fails in the websocket requests.
Then, when reconnecting (or in this case, connecting), it would be great to be able to pass new params (e.g. in this case, the fetched authentication token).
Right now, I work around this by connecting immediately (which logs errors), and when the token was acquired doing:
(sente/chsk-reconnect!
(-> chsk
(assoc-in [:ws-chsk-opts :params :auth-token] token)
(assoc-in [:ajax-chsk-opts :params :auth-token] token)))
Would you accept a patch for this functionality?
Hi Michi,
Would be happy to look at a PR (maybe 2 separate PRs for the 2 items mentioned above?)- thanks! :+1:
Edit to add: Otherwise please 👍 if someone else is reading this and interested in the feature.