Adding Asynchronous Events to Contexts

With all of that out of the way, we can add the ActionCable subscription back to the system, but we have a logistical problem to deal with first.

The logistical problem is that the ActionCable subscription needs to both be global and have external access to the existing VenueContext reducer. It needs to be global because multiple components may need access to the subscription data. But it also needs to be external from the VenueContext because the ActionCable subscription uses the concert_id, which is now stored as data in the state. But it will also need to use the dispatch function because the subscription receives data about what tickets have been held from the ActionCable channel, and it will need 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.