Possible interactions range from updating a single element's value to replacing entire sections of content. You can even dispatch client-side DOM events from the server. Also, updates don't need to be initiated by the user. For example, CableReady can update your UI in response to things happening on the server, such as long running ActiveJobs or activity from API calls and webhooks. It's never been easier to notify users of site wide activity.
CableReady builds on top of ActionCable and allows you to emit DOM instructions from the server that are automatically executed on the client. It expands the role of web sockets in the Rails ecosystem and elevates Rails as a viable highly performant alternative to the Single Page App.
CableReady supports the following DOM operations that can be triggered from server-side Ruby code.
As with other new tools, the potential use cases are only limited by your imagination. For example, CableReady provides the foundation for incredible libraries like StimulusReflex.
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