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 8, â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 ...
Get Modern Front-End Development for Rails, 2nd Edition 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.