Welcome

Your server-side Ruby can make magic happen on the client, in real-time

What is CableReady?

CableReady is a Ruby gem that lets you create great real-time user experiences by triggering client-side DOM changes, events and notifications over ActionCable web sockets. These commands are called operations.

Unlike Ajax calls, operations are not always initiated by user activity. You can broadcast one or many operations at once from inside a Reflex, as well as ActiveRecord callbacks, ActiveJobs, controller actions, rake tasks and in response to API calls and webhooks.

Operations can be broadcast to one person, every person online, or ad hoc groups of people - making real-time notifications, live comments on a blog post, form validations, collaborative editing, shared media viewing, endless page scrolling and lazy asset loading laughably trivial.

As the secret weapon primary dependency powering StimulusReflex, CableReady establishes a standard for programmatically updating browser state with no need for custom JavaScript.

Get Involved. We are stronger together! Please join us in #cableready on Discord.

GitHub stars GitHub forks Twitter follow

Why should I use CableReady?

Perhaps you've grown tired of the ever-growing complexity of the JS ecosystem. Single Page Applications are frequently lauded as the only way to build "modern" sites... even though we remember how easily one person could build powerful sites with Rails in 2004.

Or maybe you've realized that trying to synchronize state between the client and server over a stateless protocol is a Sisyphean task. How much time and energy could we reclaim for more interesting problems if we didn't need to write complex branching UI logic to update what the user sees?

It all comes down to The Great Surplus.

CableReady enables a radical new style of development, and it can make you literally 10x more productive than people who don't have it. Will you use your surplus for good... or for awesome?

Goals

  • Build reactive UIs without client state 🥏

  • Break free of the request-response lifecycle 🤹

  • Increase functionality, not complexity 🪁

  • Act as a force multiplier for StimulusJS 🔨

Just how fast are we talking about?

What can I do with it?

CableReady currently boasts 22 different operations that can be triggered from server-side Ruby code:

Operations Available

Element Mutation

morph, inner_html, outer_html, text_content, insert_adjacent_html, insert_adjacent_text, remove, set_property, set_value

CSS Mutation

add_css_class, remove_css_class

Style Mutation

set_style, set_styles

Dataset Mutation

set_dataset_property

Attribute Mutation

set_attribute, remove_attribute

DOM Events

dispatch_event

Cookies

set_cookie

Notifications

console_log, notification

Navigation

push_state, set_focus

Learn more about ActionCable to help you get the most out of CableReady.

Can I see an example?

This is a simple example that demonstrates how to set an element's value.

cable_ready["MyChannel"].set_value(
selector: "#my-element",
value: "A new value from the server"
)
cable_ready.broadcast

In this example, all clients connected to MyChannel will receive the broadcast and will update the DOM element to the new value.