React and ActionCable
Currently, our concert show page makes a fetch call to the server to determine the current status of the seats on the page, and it makes a POST call to put a seat on hold after you click on it. We can replace both of these calls with a single ActionCable subscription—granting, of course, that this is an absurdly minimalist implementation since we’re not doing a full security setup or complicated state transitions or anything like that.
ConcertChannel on the Server
Server side, we need to create a new ActionCable channel. This one will have the same subscribe method as our previous channel, but we need to add a method for our client side to call to actually reserve a ticket:
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.