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.
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?
Build reactive UIs without client state 🥏
Break free of the request-response lifecycle 🤹
Increase functionality, not complexity 🪁
Act as a force multiplier for StimulusJS 🔨
CableReady currently boasts 22 different operations that can be triggered from server-side Ruby code:
morph, inner_html, outer_html, text_content, insert_adjacent_html, insert_adjacent_text, remove, set_property, set_value
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