after_createcallback to demonstrate welcoming a new user.
ExampleChannelthat we created in the Setup will send any operations broadcast to
visitorsto all currently subscribed clients. In the code above, everyone on the site will see a Console Log message welcoming the latest member.
cable_readymultiple times to add more operations to the queue. Since
cable_readyis a singleton instance, you can continue to add operations to the queue even across multiple methods, or a recursive function.
broadcast, operations will accumulate for the specified Channel stream identifier.
cable_ready["visitors"]you are presented with a
CableReady::Channelsobject, which supports method chaining. This is a fancy way of saying that you can link up as many operations in sequence as you want, and they will ultimately be broadcast in the order that they were created.
broadcastmethod can conclude the chain, meaning that you can send a console message to everyone looking at your site with: