[Feature Request] hooks for ActionCable client errors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Feature Request] hooks for ActionCable client errors

Dan McClory

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Request] hooks for ActionCable client errors

Rafael Sales
I have the same problem.
Currently the client interface is too simple.

I'd love to have an API similar to https://github.com/apollographql/subscriptions-transport-ws


On Wednesday, February 28, 2018 at 8:41:53 PM UTC-3, Dan McClory wrote:

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.