Add ActionCable channel/connection load hooks

This commit is contained in:
Vladimir Dementyev 2019-01-29 22:07:49 -05:00
parent 94d54fa4ab
commit 8ed276b2f7
No known key found for this signature in database
GPG Key ID: 8E0A19D3D1EDF5EB
4 changed files with 19 additions and 0 deletions

@ -1,3 +1,16 @@
* Add `:action_cable_connection` and `:action_cable_channel` load hooks.
You can use them to extend `ActionCable::Connection::Base` and `ActionCable::Channel::Base`
functionality:
```ruby
ActiveSupport.on_load(:action_cable_channel) do
# do something in the context of ActionCable::Channel::Base
end
```
*Vladimir Dementyev*
* Add `Channel::Base#broadcast_to`.
You can now call `broadcast_to` within a channel action, which equals to

@ -307,3 +307,5 @@ def transmit_subscription_rejection
end
end
end
ActiveSupport.run_load_hooks(:action_cable_channel, ActionCable::Channel::Base)

@ -260,3 +260,5 @@ def successful_request_message
end
end
end
ActiveSupport.run_load_hooks(:action_cable_connection, ActionCable::Connection::Base)

@ -1497,6 +1497,8 @@ To hook into the initialization process of one of the following classes use the
| Class | Available Hooks |
| --------------------------------- | ------------------------------------ |
| `ActionCable` | `action_cable` |
| `ActionCable::Channel::Base` | `action_cable_channel` |
| `ActionCable::Connection::Base` | `action_cable_connection` |
| `ActionController::API` | `action_controller_api` |
| `ActionController::API` | `action_controller` |
| `ActionController::Base` | `action_controller_base` |