Hi everyone,
Recently I was trying to show an alert if the ActionCable connection became closed. I poked around the code and learned that there wasn’t a great way to hook into the events.
I ended up polling the connection status with:
setInterval( () => { if (App.cable.connection.getStatus() === "closed") { callSideEffectCode() } }, 5000)
But I’d rather have been able to just write something like:
App.cable.customHandler["closed"] = callSideEffectCode
Would people be interested in a feature that adds support for custom callbacks for the 4 types of WebSocket events that ActionCable.Connection handles? I think it’d be a very small PR.
thanks,
Dan