module Callbacks
Ruby on Rails 7.2.3
Since v5.2.8.1Action Cable Channel Callbacks
Action Cable Channel provides callback hooks that are invoked during the life cycle of a channel:
-
after_subscribe (aliased as on_subscribe)
-
after_unsubscribe (aliased as on_unsubscribe)
Example
class ChatChannel < ApplicationCable::Channel
after_subscribe :send_welcome_message, unless: :subscription_rejected?
after_subscribe :track_subscription
private
def send_welcome_message
broadcast_to(...)
end
def track_subscription
# ...
end
end
Namespace
Modules
Includes
Extends
Used by
Included by (1)
Methods (inherited)
From ActiveSupport::Callbacks (1)
From ActiveSupport::Concern (3)
- # class_methods
- # included
- # prepended
From ActiveSupport::DescendantsTracker (3)
- # descendants
- self. descendants
- self. subclasses