app.<%= class_name.camelize(:lower) %>Channel = app.cable.subscriptions.create "<%= class_name %>Channel", connected: -> # Called when the subscription is ready for use on the server if app.currentPage currentPage.trigger 'channel-connected', ['<%= class_name.underscore %>'] disconnected: -> # Called when the subscription has been terminated by the server if app.currentPage currentPage.trigger 'channel-disconnected', ['<%= class_name.underscore %>'] received: (data) -> # Called when there's incoming data on the websocket for this channel if app.currentPage currentPage.trigger 'channel-received', ['<%= class_name.underscore %>', data] <% actions.each do |action| -%> <%= action %>: -> @perform '<%= action %>' <% end -%>