Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rsamoilov committed Jul 8, 2024
1 parent f015364 commit 79be47f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/rage/cable/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,20 @@ def __prepare_id_method(method_name)
# before_subscribe do
# ...
# end
# @example
# before_subscribe :my_method, if: -> { ... }
def before_subscribe(action_name = nil, **opts, &block)
add_action(:before_subscribe, action_name, **opts, &block)
end
# Register a new `after_subscribe` hook that will be called after the {subscribed} method.
#
# @example
# after_subscribe do
# ...
# end
# @example
# after_subscribe :my_method, unless: :subscription_rejected?
# @note This callback will be triggered even if the subscription was rejected with the {reject} method.
def after_subscribe(action_name = nil, **opts, &block)
add_action(:after_subscribe, action_name, **opts, &block)
Expand Down Expand Up @@ -252,7 +260,7 @@ def rescue_from(*klasses, with: nil, &block)
# @param every [Integer] the calling period in seconds
# @example
# periodically every: 3.minutes do
# transmit action: :update_count, count: current_count
# transmit({ action: :update_count, count: current_count })
# end
# @example
# periodically :update_count, every: 3.minutes
Expand Down Expand Up @@ -406,6 +414,9 @@ def stream_from(stream)
# @param stream [String] the name of the stream
# @param data [Object] the data to send to the clients
# @example
# def subscribed
# broadcast("notifications", { message: "A new member has joined!" })
# end
def broadcast(stream, data)
Rage.config.cable.protocol.broadcast(stream, data)
end
Expand Down

0 comments on commit 79be47f

Please sign in to comment.