Stimulus and ActionCable
The Turbo ActionCable helpers are great, but they don’t cover every use case for ActionCable we might have. You may need to use ActionCable by using custom JavaScript on the client, either because there is an already existing endpoint or because your task doesn’t quite fit with the Turbo patterns. In this section, we’re going to use ActionCable to rebuild the “sold out” feature we previously built using polling in Chapter 9, Talking to the Server.
To use ActionCable directly, we need to create objects on the client and on the server. On the server, we have channels and connections. An ActionCable channel is roughly analogous to a Rails controller. The channel is where you put the code that responds to data the server ...
Get Modern Front-End Development for Rails now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.