Connection
represents the fully-abstracted raw websocket protocol. Properly configured, one WS connection can support an unbound number of Channels, and it will work hard to keep you connected even if your bandwidth is spotty. Connections are also where most developers implement authentication.Channel
is a theme-specific conduit for exchanging messages via the Connection. These conduits are referenced by the developer using either a string or a constant. Channel is designed with a "hub-and-spoke" distribution model in which there is no concept of direct, client-to-client message passing. Implemented as a sibling pair of Ruby and JavaScript classes, Channel provides the flexible conceptual chassis upon which real-time applications can be built in Rails.Subscription
is a wire made out of intention, stretched between the firehose "stream" interfaces of the Channel and the densely connected tree your client-side code taps like a spigot. Subscriptions might not be free, but they certainly are quite cheap.verifyNotMutable
that actively prevents the server from overwriting input, textarea and select elements while they are active (have focus).selector
option provided to DOM-mutating operations expects a CSS selector that resolves to one single DOM element.select_all
option which instructs CableReady to operate on one or many DOM elements returned by the selector
query.sushi
:xpath: true
as a parameter argument when enqueueing the operation.select_all
option, although if this is important to your application, let us know and we'll consider a more flexible implementation.selector
element if present, otherwise they will default to document
.cable-ready:before-inner-html
and cable-ready:after-morph
.detail
accessors as their DOM event siblings.detail
object to access all of the options passed to CableReady when the operation was enqueued.detail
object. Remember, all snake_case keys will be automatically converted to camelCase:cable-ready:before-{operation}
and cable-ready:after-{operation}
events. If you create an event handler to listen for "before" events, you can access and modify most of the parameters passed when queueing the operation on the server.set_cookie
example, the event handler is able to intercept the operation mid-flight and change the parameters.event.detail
object, this new value will be picked up by the other elements associated with the current operation that have not been processed, yet.cancel
parameter that is designed to be interacted with in a "before" event handler on the client. cancel
must be false
or undefined
when the event handler returns for the operation to run.cancel
parameter, it's an important tool to have available when building sophisticated client user interfaces.detail
data, if your operation is processing multiple elements, each element will emit its own "before" and "after" events. You could cancel an operation for a given element and then un-cancel it for later elements.focusSelector
parameter that allows you to specify a CSS selector to which element should be active (receive focus) after the operation completes.focusSelector
is not specified, the focus will go to the element that was active immediately before the operation was executed.cableReady
key present.current_user
using the UsersChannel
:UsersChannel
becomes users
while ActiveRecord has a to_gid_param
.broadcast
with no operations and still take advantage of the received
handler:identified_by
one or more objects. These can be strings or ActiveRecord model resources. It is only using one of these connection identifiers that you can forcibly disconnect a client connection entirely.remote_connections
mapping. Otherwise, the following will fail silently:identified_by
both current_user
and session_id
, it will raise an error if your user hasn't authenticated yet. That's no good!all?
to any?