Simple demo of Rails 5 ActionCable based on Pluralsight tutorial
- Visiting
/
of the app causes rendering of the messages stored in the db using_message
partial cable.js
instantiates consumer websocket api and stores it inApp.cable
room.coffee
creates subscription to theRoomChannel
websocket channel- It also creates handler for sending new messages which triggers
this.perform
sendingspeak
message with the content - Upon receiving
speak
message, server createsMessage
entity in the database with appended content after_create_commit
onMessage
model enqueues aMessageBroadcastJob
- Upon performing the job, it broadcasts the received message, using
_message
partial, to theroom_channel
room.coffee
code handles the received data by invokingreceived
handler and appending the message to the DOM