class

ActionCable::Channel::Base

Inherits Reference < Object

Constructors

new(connection : ConnectionAPI, identifier : String, params : Hash(String, String) = {} of String => String)
Source

Class methods

broadcast_to(broadcastables : Broadcastable | Array(Broadcastable), payload : String | Hash(String, CableValue)) : Nil
Source
broadcasting_for(broadcastables : Broadcastable | Array(Broadcastable)) : String

--- stream_for / broadcast_to (gem's Streams + Naming) ---------- broadcasting_for: [channel_name, *broadcastables].join(":"), каждый элемент — gid AR-записи или to_s (оракул stream_for_expected.yml).

Source
periodic_timers

Timers registered for this class via periodically (generated per subclass below; subclasses inherit ancestor timers).

Source

Instance methods

__dispatch_action(action : String, data : Hash(String, String)) : Bool

Overridden per-subclass by end-of-program codegen (below).

Source
__fire_periodic(name : String) : Bool

Overridden per-subclass by end-of-program codegen (below): block timers dispatch to their generated methods.

Source
broadcast_to(broadcastables : Broadcastable | Array(Broadcastable), payload : String | Hash(String, CableValue)) : Nil
Source
broadcasting_for(broadcastables : Broadcastable | Array(Broadcastable)) : String
Source
connection
identifier
params
perform_action(data : Hash(String, String)) : Nil
Source
reject
Source
rejected?
Source
stop_all_streams
Source
stop_stream_for(broadcastables : Broadcastable | Array(Broadcastable)) : Nil
Source
stream_for(broadcastables : Broadcastable | Array(Broadcastable), callback : Proc(String, Nil) | Nil = nil) : Nil
Source
stream_from(broadcasting : String, callback : Proc(String, Nil) | Nil = nil) : Nil
Source
stream_names

Probe surface for the private Ruby #streams hash (name → callback).

Source
stream_or_reject_for(broadcastables : Broadcastable | Array(Broadcastable) | Nil) : Nil
Source
subscribe_to_channel
Source
subscribed

Override in subclasses — set up streams here.

Source
transmit(data : CableValue) : Nil
Source
unsubscribe_from_channel
Source
unsubscribed

Override in subclasses — cleanup here.

Source
unsubscribed?
Source

Macros

periodically(method_name = nil, every = nil)

Periodically performs a task while the channel is subscribed (the gem's Channel::PeriodicTimers, timer semantics 1:1): timers start after #subscribed (after_subscribe) and stop on unsubscribe_from_channel (after_unsubscribe).

periodically :transmit_progress, every: 5.seconds periodically every: 3.minutes do transmit({action: "update_count"} of String => CableValue) end

A method name or a block, plus the every: interval (a Time::Span or a number of seconds). Deviation from the Ruby DSL: this is a macro (class-body DSL), so the callable form is a block or a method name only; the block runs as a generated channel method with the channel as self, like Ruby's instance_exec.

Source