Action Cable 的 Channel 的 Callbacks¶ ↑
Action Cable 的 Channel 在 channel 的生命周期中提供被调用的回调钩子
-
after_subscribe (别名为 on_subscribe)
示例¶ ↑
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
命名空间
包含的模块