[Feature Request] hooks for ActionCable client errors

15 views
Skip to first unread message

Dan McClory

unread,
Feb 28, 2018, 6:41:53 PM2/28/18
to Ruby on Rails: Core

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

Rafael Sales

unread,
Sep 5, 2018, 7:57:42 PM9/5/18
to Ruby on Rails: Core
I have the same problem.
Currently the client interface is too simple.

Reply all
Reply to author
Forward
0 new messages