Chapter 9Immediate Communication with ActionCable
In the last chapter, we talked about communicating with the server using regular HTTP requests and receiving either HTML or JSON in response. One feature of our server interactions in both Stimulus and React is that we are simulating a real-time connection with the server by polling the server repeatedly. Polling this way has a couple of potential drawbacks. Thereâs some extra overhead to make all the HTTP calls locally, and pestering the server often can have bad performance implications.
An alternative for client-server communications is to use the WebSocket protocol. The WebSocket protocol allows a client and a server to communicate over a single long-lived connection. A common analogy ...
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.