Iteration F5: Broadcasting Updates with Action Cable
Up until now, our users’ web browsers have requested information from our Rails app, either by going directly to a URL or by clicking a link or button. It’s also possible to send information from our Rails app to our users’ browsers without a direct request. The technology that enables this is called Web Sockets.[62] Prior to Rails 5, setting this up was fairly involved, but Rails 5 introduced Action Cable, which simplifies pushing data to all connected browsers.
We can use Action Cable and Web Sockets to broadcast price updates to the users browsing the catalog. To see why we’d want to, bring up the Depot application in two browser windows or tabs. In the first window, display the catalog. ...
Get Agile Web Development with Rails 5.1 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.